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

public interface ImmutableSequencedCollection<E> extends ImmutableCollection<E>, ReadOnlySequencedCollection<E>
An interface to an immutable collection with a well-defined iteration order; the implementation guarantees that the state of the collection does not change.

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 Details

    • add

      Description copied from interface: ImmutableCollection
      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.

      Specified by:
      add in interface ImmutableCollection<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

      ImmutableSequencedCollection<E> addAll(Iterable<? extends E> c)
      Description copied from interface: ImmutableCollection
      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.

      Specified by:
      addAll in interface ImmutableCollection<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

      ImmutableSequencedCollection<E> addFirst(@Nullable E element)
      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

      ImmutableSequencedCollection<E> addLast(@Nullable E element)
      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: ImmutableCollection
      Returns an empty collection instance that has the specified element type.
      Specified by:
      empty in interface ImmutableCollection<E>
      Type Parameters:
      T - the element type of the returned collection
      Returns:
      an empty collection of the specified element type.
    • remove

      ImmutableSequencedCollection<E> remove(E element)
      Description copied from interface: ImmutableCollection
      Returns a copy of this collection that contains all elements of this collection except the specified element.
      Specified by:
      remove in interface ImmutableCollection<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: ImmutableCollection
      Returns a copy of this collection that contains all elements of this collection except the elements of the specified collection.
      Specified by:
      removeAll in interface ImmutableCollection<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

      default ImmutableSequencedCollection<E> 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

      default ImmutableSequencedCollection<E> 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: ImmutableCollection
      Returns a copy of this collection that contains only elements that are in this collection and in the specified collection.
      Specified by:
      retainAll in interface ImmutableCollection<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