Closed Bug 1166157 Opened 10 years ago Closed 10 years ago

Implement enumerating method for nsTArray which allows removing element

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox41 --- affected

People

(Reporter: xidorn, Unassigned)

Details

Attachments

(1 file)

We should have an enumerating method for nsTArray like nsTHashtable::EnumerateEntries, which allows removing elements. A bonus would be that we could do it with lambda, so that we don't need to use a "void* aUserArg" hack.
Attached patch patchSplinter Review
Attachment #8607345 - Flags: review?(nfroyd)
Comment on attachment 8607345 [details] [diff] [review] patch Review of attachment 8607345 [details] [diff] [review]: ----------------------------------------------------------------- Why not change the iterator returned by begin()/end()/etc. to be stable in the face of removals?
Attachment #8607345 - Flags: review?(nfroyd)
To make the iterator removal-stable, we would have to either accept a terrible O(n) time for each removal, or add burden to normal iterating which doesn't need to remove elements. I guess the first opinion is probably fine, as we probably won't usually do removal that frequently.
It's probably tricky to make iterator support removal, especially consider that the direction of an iterator can be reversed. Probably we could just use std::remove_if.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: