Module org.jhotdraw8.icollection
Interface ImmutableCollection<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
Iterable<E>,ReadOnlyCollection<E>
- All Known Subinterfaces:
ImmutableList<E>,ImmutableNavigableSet<E>,ImmutableSequencedCollection<E>,ImmutableSequencedSet<E>,ImmutableSet<E>,ImmutableSortedSet<E>
- All Known Implementing Classes:
ChampSet,ChampVectorSet,ImmutableSetFacade,RedBlackSet,VectorList
An interface to an immutable collection; the implementation
guarantees that the state of the collection does not change.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this collection that contains all elements of this collection and also the specified element.Returns a copy of this collection that contains all elements of this collection and also all elements of the specified collection.<T> @NonNull ImmutableCollection<T> empty()Returns an empty collection instance that has the specified element type.default ImmutableCollection<E> Retains all elements in this collection that satisfy the specified predicate.intmaxSize()Returns the maximal number of elements that this collection type can holdReturns a copy of this collection that contains all elements of this collection except the specified element.Returns a copy of this collection that contains all elements of this collection except the elements of the specified collection.Returns a copy of this collection that contains only elements that are in this collection and in the specified collection.Returns a mutable copy of this collection.Methods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
asCollection, characteristics, contains, containsAll, isEmpty, iterator, size, stream, toArray, toArray
-
Method Details
-
add
Returns a copy of this collection that contains all elements of this collection and also the specified element.A collection may prevent that the same element can be added more than once.
- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element, or a different collection instance with the element added
-
addAll
Returns a copy of this collection that contains all elements of this collection and also all elements of the specified collection.A collection may prevent that the same element can be added more than once.
- Parameters:
c- a collection to be added to this collection- Returns:
- this collection instance if it already contains the elements, or a different collection instance with the elements added
-
empty
Returns an empty collection instance that has the specified element type.- Type Parameters:
T- the element type of the returned collection- Returns:
- an empty collection of the specified element type.
-
filter
Retains all elements in this collection that satisfy the specified predicate.- Parameters:
p- a predicate- Returns:
- a collection that only contains elements that satisfy the predicate
-
maxSize
int maxSize()Returns the maximal number of elements that this collection type can hold- Returns:
- the maximal size
-
remove
Returns a copy of this collection that contains all elements of this collection except the specified element.- Parameters:
element- an element- Returns:
- this collection instance if it already does not contain the element, or a different collection instance with the element removed
-
removeAll
Returns a copy of this collection that contains all elements of this collection except the elements of the specified collection.- Parameters:
c- a collection with elements to be removed from this collection- Returns:
- this collection instance if it already does not contain the elements, or a different collection instance with the elements removed
-
retainAll
Returns a copy of this collection that contains only elements that are in this collection and in the specified collection.- Parameters:
c- a collection with elements to be retained in this collection- Returns:
- this collection instance if it has not changed, or a different collection instance with elements removed
-
toMutable
@NonNull Collection<E> toMutable()Returns a mutable copy of this collection.- Returns:
- a mutable copy.
-