E - the type of elements in this collectionpublic interface ObjCollection<E> extends Collection<E>, Container
Collection interface.
All methods of Collection interface defined in terms of elements equality and
referring to Object.equals(Object) method are supposed to use equivalence()
in this interface. Thus in some sense ObjCollection violates general Collection
contract, but this approach provides a great flexibility. If you need strict Collection
implementation, you can always construct an ObjCollection with default equality,
i. e. equivalence() == Equivalence.defaultEquality().
See Collection
mutability matrix for methods which are supported by ObjCollections with the specific
mutability. Among methods,
defined in this interface directly, removeIf(Predicate) is supported only by collections
of mutable profile, others are supported by ObjCollections with any mutability
profile.
| Modifier and Type | Method and Description |
|---|---|
ObjCursor<E> |
cursor()
Returns a new cursor over this collection's elements.
|
Equivalence<E> |
equivalence()
Returns the equivalence strategy for elements in this collection.
|
void |
forEach(Consumer<? super E> action)
Performs the given action for each element of this collection until all elements have been
processed or the action throws an exception.
|
boolean |
forEachWhile(Predicate<? super E> predicate)
Checks the given
predicate on each element of this collection until all element
have been processed or the predicate returns false for some element,
or throws an Exception. |
ObjIterator<E> |
iterator()
Returns a new iterator over this collection's elements.
|
boolean |
removeIf(Predicate<? super E> filter)
Removes all of the elements of this collection that satisfy the given predicate.
|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArrayclear, ensureCapacity, isEmpty, shrink, size, sizeAsLong@Nonnull Equivalence<E> equivalence()
Collection interface which defined in terms of Object.equals(Object)
equality of elements, for example, Collection.contains(Object) and Collection.remove(Object),
are supposed to use this equivalence instead.void forEach(@Nonnull Consumer<? super E> action)
action - the action to be performed for each elementboolean forEachWhile(@Nonnull Predicate<? super E> predicate)
predicate on each element of this collection until all element
have been processed or the predicate returns false for some element,
or throws an Exception. Exceptions thrown by the predicate are relayed to the caller.
Unless otherwise specified by the implementing class, elements are checked by the predicate in the order of iteration (if an iteration order is specified).
If this collection is empty, this method returns true immediately.
predicate - the predicate to be checked for each element of this collectiontrue if the predicate returned true for all elements of this
collection, false if it returned false for the element@Nonnull ObjCursor<E> cursor()
@Nonnull ObjIterator<E> iterator()
iterator in interface Collection<E>iterator in interface Iterable<E>boolean removeIf(@Nonnull Predicate<? super E> filter)
filter - a predicate which returns true for elements to be removedtrue if any elements were removedNullPointerException - if the specified filter is nullUnsupportedOperationException - if elements cannot be removed from this collection.
Implementations may throw this exception if a matching element cannot be removed
or if, in general, removal is not supported.