vigna / fastutil

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

Fix removeIf ambiguity #199

Closed techsy730 closed 3 years ago

techsy730 commented 3 years ago

The removeIf method had an ambiguity if you tried to use it with lambdas, requiring you to cast to a functor type yourself.

This change fixes it so it chooses a proper primitive Predicate.

It basically applies what was done to forEach and forEachRemaining to removeIf.

vigna commented 3 years ago

So in the JDK-primitive case there would always be a delegation in case we use a lambda. Wouldn't be more appealing to have removeIf(KEY_PREDICATE) contain the actual implementation and removeIf(JDK_PRIMITIVE_PREDICATE) to use a test / casting as in the non-JDK-primitive case? Why the different treatment?