Hi Emilio,

right, removing entries isn't possible within a range-based for, and
it's neither with STL associative containers such as std::map AFAIK.
It would probably be possible to add a method to nsBaseHashtable with
signature:

const_iterator Remove(const_iterator);

to support the idiom used with STL associative containers [1]. If you
find that useful, please open a bug. I will try to give it a look
then.

Best wishes
Simon

[1] https://stackoverflow.com/a/8234813/2019765

On Wed, Oct 2, 2019 at 3:52 PM Emilio Cobos Álvarez <emi...@crisal.io> wrote:
>
> When trying to port some of the usage in layout/style to this, I
> realized that there's no way to remove entries while iterating, so you
> can't port [1] to this for example.
>
> Is there something I've missed? Should I file a bug about it?
>
> Or should we just keep using old style iterators for that?
>
> Cheers,
>
>   -- Emilio
>
> [1]:
> https://searchfox.org/mozilla-central/rev/f372e8a46ef7659ef61be9938ec2a3ea34d343c6/layout/style/Loader.cpp#673
>
> On 10/2/19 3:02 PM, Emilio Cobos Álvarez wrote:
> > This is great, thanks for doing this!
> >
> >   -- Emilio
> >
> > On 10/2/19 12:15 PM, Simon Giesecke wrote:
> >> Hi,
> >>
> >> I recently [1] added STL-style iterators and begin/cbegin/end/cend
> >> member functions to nsBaseHashtable. This means that it is now
> >> possible to use range-based for and STL algorithms operating on
> >> iterators with all of its subclasses, which include nsClassHashtable,
> >> nsDataHashtable, nsInterfaceHashtable, nsJSThingHashtable and
> >> nsRefPtrHashtable.
> >>
> >> I also added an overview on existing support for range-based for and
> >> STL-style iterators in Mozilla data structures on MDN  at [2].
> >>
> >> If you have any questions or issues, please let me know or NI me on
> >> Bugzilla.
> >>
> >> Best wishes
> >> Simon
> >>
> >> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1575479
> >> [2]
> >> https://developer.mozilla.org/en-US/docs/Mozilla/Using_CXX_in_Mozilla_code#Mozilla_data_structures_and_standard_C_ranges_and_iterators
> >>
> >> _______________________________________________
> >> dev-platform mailing list
> >> dev-platform@lists.mozilla.org
> >> https://lists.mozilla.org/listinfo/dev-platform
> >>
> > _______________________________________________
> > dev-platform mailing list
> > dev-platform@lists.mozilla.org
> > https://lists.mozilla.org/listinfo/dev-platform
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to