Vivek Rao
Vivek Rao

Reputation: 586

How would you do a removeIf on a list or set for primitives in eclipse collections?

On regular java collections it's possible to remove an element given an input Predicate. persons.removeIf(person -> person.isMale());

In eclipse collections it seems possible to do this as long as the collection being used extends Iterable<T>.

For primitive collections that extend PrimitiveIterable, there doesn't seem to be a method provided to do the same. Is it not supported? If not, why?

EDIT: I should add that I'm looking for a method that removes an item in-place without creating a new set, as reject does.

Upvotes: 1

Views: 475

Answers (1)

Donald Raab
Donald Raab

Reputation: 6706

The method removeIf doesn't exist for mutable primitive collections in Eclipse Collections today. It makes sense to add, as it has been on the mutable object collections since at least version 2.0 which was released in August 2012. I just started working on it. It can be added as a default method so should hopefully be available in the 9.1 release.

Update: The method removeIf was added to mutable primitive collections in the 9.1 release of Eclipse Collections.

Upvotes: 3

Related Questions