You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original issue created by ivankoblik on 2010-04-28 at 10:33 AM
Would be nice to have a standard predicate to do referential equality check.
Possible use case:
ImmutableSet<Object> filteredSet =
ImmutableSet.copyOf(
Collections2.filter(
Predicates.not(
Predicates.sameAs(objectToRemove)
)));
I'm not sure how efficient it is, but it's a nifty way of "removing"
elements from immutable collections. Would be glad to learn if there's a
better way of doing it.
The text was updated successfully, but these errors were encountered:
Predicates.equalTo() is what you want for this 99% of the time. We used to have a sameAs() predicate internally,
but virtually everyone who used it should have used equalTo(), so we got rid of it.
Btw, for sets you also have the option of Sets.difference(set, ImmutableSet.of(objectToRemove)) (optionally
adding .immutableCopy() to the end of that).
Original issue created by ivankoblik on 2010-04-28 at 10:33 AM
Would be nice to have a standard predicate to do referential equality check.
Possible use case:
ImmutableSet<Object> filteredSet =
ImmutableSet.copyOf(
Collections2.filter(
Predicates.not(
Predicates.sameAs(objectToRemove)
)));
I'm not sure how efficient it is, but it's a nifty way of "removing"
elements from immutable collections. Would be glad to learn if there's a
better way of doing it.
The text was updated successfully, but these errors were encountered: