Interface ImmutableSequencedCollection<E>
- Type Parameters:
E- the element type
- All Superinterfaces:
ImmutableCollection<E>,Iterable<E>,ReadOnlyCollection<E>,ReadOnlySequencedCollection<E>
- All Known Subinterfaces:
ImmutableList<E>,ImmutableSequencedSet<E>
- All Known Implementing Classes:
ChampVectorSet,VectorList
An interface to an immutable sequenced collection provides methods for creating a new immutable sequenced collection with added or removed elements, without changing the original immutable sequenced collection.
-
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.Returns a copy of this collection that contains all elements of this collection and also the specified element as the first element in the iteration order.Returns a copy of this collection that contains all elements of this collection and also the specified element as the last element in the iteration order.empty()Returns an empty collection instance that has the specified element type.Returns 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.default ImmutableSequencedCollection<E> Returns a copy of this set that contains all elements of this set except the first.default ImmutableSequencedCollection<E> Returns a copy of this set that contains all elements of this set except the last.Returns a copy of this collection that contains only elements that are in this collection and in the specified collection.Methods inherited from interface org.jhotdraw8.icollection.immutable.ImmutableCollection
filter, maxSize, toMutableMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
characteristics, contains, containsAll, isEmpty, iterator, size, stream, toArray, toArrayMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySequencedCollection
asCollection, getFirst, getLast, readOnlyReversed
-
Method Details
-
add
Description copied from interface:ImmutableCollectionReturns 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.
- Specified by:
addin interfaceImmutableCollection<E>- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element, or a different collection instance with the element added
-
addAll
Description copied from interface:ImmutableCollectionReturns 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.
- Specified by:
addAllin interfaceImmutableCollection<E>- 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
-
addFirst
Returns a copy of this collection that contains all elements of this collection and also the specified element as the first element in the iteration order.A collection may prevent that the same element can be added more than once.
If the iteration order is based on an ordering relation of the elements, then the element is only the first in a sequence of elements with the same ordering relation; which is not necessarily the first in the total iteration order.
- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element as the first in the iteration order, or a different collection instance with the element added as the first in the iteration order
-
addLast
Returns a copy of this collection that contains all elements of this collection and also the specified element as the last element in the iteration order.A collection may prevent that the same element can be added more than once.
If the iteration order is based on an ordering relation of the elements, then the element is only the last in a sequence of elements with the same ordering relation; which is not necessarily the last in the total iteration order.
- Parameters:
element- an element- Returns:
- this collection instance if it already contains the element as the last in the iteration order, or a different collection instance with the element added as the last in the iteration order
-
empty
Description copied from interface:ImmutableCollectionReturns an empty collection instance that has the specified element type.- Specified by:
emptyin interfaceImmutableCollection<E>- Type Parameters:
T- the element type of the returned collection- Returns:
- an empty collection of the specified element type.
-
remove
Description copied from interface:ImmutableCollectionReturns a copy of this collection that contains all elements of this collection except the specified element.- Specified by:
removein interfaceImmutableCollection<E>- 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
Description copied from interface:ImmutableCollectionReturns a copy of this collection that contains all elements of this collection except the elements of the specified collection.- Specified by:
removeAllin interfaceImmutableCollection<E>- 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
-
removeFirst
Returns a copy of this set that contains all elements of this set except the first.- Returns:
- a new set instance with the first element removed
- Throws:
NoSuchElementException- if this set is empty
-
removeLast
Returns a copy of this set that contains all elements of this set except the last.- Returns:
- a new set instance with the last element removed
- Throws:
NoSuchElementException- if this set is empty
-
retainAll
Description copied from interface:ImmutableCollectionReturns a copy of this collection that contains only elements that are in this collection and in the specified collection.- Specified by:
retainAllin interfaceImmutableCollection<E>- 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
-