vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.74k stars 194 forks source link

efficient removeIf for ArrayList #299

Closed barakugav closed 12 months ago

barakugav commented 1 year ago

The current implementation of removeIf uses the iterator of the list, and iterator.remove(). This is very inefficient, as each remove() call may require a shift of all the following elements. The new implementation is similar to removeAll(), and runs in O(n) overall

vigna commented 1 year ago

Nice! Could you please add a unit test for both the primitive and the object version (e.g., adding it to IntArrayListTest and ObjectArrayListTest)? 

barakugav commented 12 months ago

It seems there are already few tests for it.

In IntArrayListTest: testRemoveIf testRemoveIf_jdkPredicate testRemoveIf_objectPredicate in ObjectArrayListTest: testRemoveIf

Just added a missing import, all seems to pass. Do you think there is a need for more?

barakugav commented 12 months ago

Also, i see there is no CI for the repo. Did you consider setting up one? The JUnit tests could be run on each pull request automatically

vigna commented 12 months ago

I consider CI a gigantic waste or resources and electricity. We have an already big enough carbon footprint, I really don't want to run tests at each push...

incaseoftrouble commented 12 months ago

@vigna As a small side note: IIRC, one can set up a manual CI so that you can with the push of a button run a CI script before you want to merge.