vigna / fastutil

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

efficient removeIf for ArrayList #299

Closed barakugav closed 1 year 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 1 year 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 1 year 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 1 year 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 1 year 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.