- Type Parameters:
E- the type of elements contained in the collection. The immutable collection is covariant on its element type.
- All Superinterfaces:
Iterable<E>
- All Known Subinterfaces:
ImmutableList<E>, ImmutableSet<E>, PersistentCollection<E>, PersistentList<E>, PersistentSet<E>
- All Known Implementing Classes:
ImmutableList.SubList
A generic immutable collection of elements. Methods in this interface support only read-only access to the collection.
Modification operations are supported through the PersistentCollection interface.
Implementors of this interface take responsibility to be immutable. Once constructed they must contain the same elements in the same order.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif this collection contains the specified element.booleancontainsAll(Collection<? extends E> elements) Returnstrueif this collection contains all elements in the specified collection.default booleanisEmpty()Returnstrueif this collection contains no elements.iterator()Returns an iterator over the elements of this collection.Returns a possibly parallelStreamwith this collection as its source.intsize()Returns the number of elements in this collection.stream()Returns a sequentialStreamwith this collection as its source.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
size
int size()Returns the number of elements in this collection. -
isEmpty
default boolean isEmpty()Returnstrueif this collection contains no elements. -
contains
Returns
trueif this collection contains the specified element.More formally, returns
trueif and only if this collection contains at least one elementesuch thatObjects.equals(o, e). -
containsAll
Returnstrueif this collection contains all elements in the specified collection. -
iterator
-
stream
-
parallelStream
-