Interface ImmutableSequencedSet<E>

Type Parameters:
E - the element type
All Superinterfaces:
ImmutableCollection<E>, ImmutableSequencedCollection<E>, ImmutableSet<E>, Iterable<E>, ReadOnlyCollection<E>, ReadOnlySequencedCollection<E>, ReadOnlySequencedSet<E>, ReadOnlySet<E>
All Known Implementing Classes:
ChampVectorSet

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

An interface to an immutable sequenced set provides methods for creating a new immutable sequenced set with added or removed elements, without changing the original immutable sequenced set.

  • Method Details

    • add

      ImmutableSequencedSet<E> add(E element)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set and also the specified element.
      Specified by:
      add in interface ImmutableCollection<E>
      Specified by:
      add in interface ImmutableSequencedCollection<E>
      Specified by:
      add in interface ImmutableSet<E>
      Parameters:
      element - an element
      Returns:
      this set instance if it already contains the element, or a different set instance with the element added
    • addAll

      default ImmutableSequencedSet<E> addAll(Iterable<? extends E> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.
      Specified by:
      addAll in interface ImmutableCollection<E>
      Specified by:
      addAll in interface ImmutableSequencedCollection<E>
      Specified by:
      addAll in interface ImmutableSet<E>
      Parameters:
      c - a collection to be added to this set
      Returns:
      this set instance if it already contains the elements, or a different set instance with the elements added
    • addFirst

      ImmutableSequencedSet<E> addFirst(@Nullable E element)
      Description copied from interface: ImmutableSequencedCollection
      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.

      Specified by:
      addFirst in interface ImmutableSequencedCollection<E>
      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

      ImmutableSequencedSet<E> addLast(@Nullable E element)
      Description copied from interface: ImmutableSequencedCollection
      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.

      Specified by:
      addLast in interface ImmutableSequencedCollection<E>
      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

      <T> ImmutableSequencedSet<T> empty()
      Description copied from interface: ImmutableSet
      Returns an empty set instance that has the specified element type.
      Specified by:
      empty in interface ImmutableCollection<E>
      Specified by:
      empty in interface ImmutableSequencedCollection<E>
      Specified by:
      empty in interface ImmutableSet<E>
      Type Parameters:
      T - the element type of the returned set
      Returns:
      an empty set of the specified element type.
    • remove

      ImmutableSequencedSet<E> remove(E element)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set except the specified element.
      Specified by:
      remove in interface ImmutableCollection<E>
      Specified by:
      remove in interface ImmutableSequencedCollection<E>
      Specified by:
      remove in interface ImmutableSet<E>
      Parameters:
      element - an element
      Returns:
      this set instance if it already does not contain the element, or a different set instance with the element removed
    • removeAll

      default ImmutableSequencedSet<E> removeAll(Iterable<?> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains all elements of this set except the elements of the specified collection.
      Specified by:
      removeAll in interface ImmutableCollection<E>
      Specified by:
      removeAll in interface ImmutableSequencedCollection<E>
      Specified by:
      removeAll in interface ImmutableSet<E>
      Parameters:
      c - a collection with elements to be removed from this set
      Returns:
      this set instance if it already does not contain the elements, or a different set instance with the elements removed
    • removeFirst

      default ImmutableSequencedSet<E> removeFirst()
      Returns a copy of this set that contains all elements of this set except the first.
      Specified by:
      removeFirst in interface ImmutableSequencedCollection<E>
      Returns:
      a new set instance with the first element removed
      Throws:
      NoSuchElementException - if this set is empty
    • removeLast

      default ImmutableSequencedSet<E> removeLast()
      Returns a copy of this set that contains all elements of this set except the last.
      Specified by:
      removeLast in interface ImmutableSequencedCollection<E>
      Returns:
      a new set instance with the last element removed
      Throws:
      NoSuchElementException - if this set is empty
    • retainAll

      default ImmutableSequencedSet<E> retainAll(Iterable<?> c)
      Description copied from interface: ImmutableSet
      Returns a copy of this set that contains only elements that are in this set and in the specified collection.
      Specified by:
      retainAll in interface ImmutableCollection<E>
      Specified by:
      retainAll in interface ImmutableSequencedCollection<E>
      Specified by:
      retainAll in interface ImmutableSet<E>
      Parameters:
      c - a collection with elements to be retained in this set
      Returns:
      this set instance if it has not changed, or a different set instance with elements removed
    • toMutable

      SequencedSet<E> toMutable()
      Description copied from interface: ImmutableSet
      Returns a mutable copy of this set.
      Specified by:
      toMutable in interface ImmutableCollection<E>
      Specified by:
      toMutable in interface ImmutableSet<E>
      Returns:
      a mutable copy.
    • reverse

      default ImmutableSequencedSet<E> reverse()
      Returns a reversed copy of this set.

      This operation may be implemented in O(N).

      Use ReadOnlySequencedSet.readOnlyReversed() if you only need to iterate in the reversed sequence over this set.

      Returns:
      a reversed copy of this set.