Interface ImmutableSortedSet<E>

Type Parameters:
E - the element type
All Superinterfaces:
ImmutableCollection<E>, ImmutableSet<E>, Iterable<E>, ReadOnlyCollection<E>, ReadOnlySequencedCollection<E>, ReadOnlySequencedSet<E>, ReadOnlySet<E>, ReadOnlySortedSet<E>
All Known Subinterfaces:
ImmutableNavigableSet<E>
All Known Implementing Classes:
RedBlackSet

public interface ImmutableSortedSet<E> extends ReadOnlySortedSet<E>, ImmutableSet<E>
An interface to an immutable sorted set; the implementation guarantees that the state of the collection does not change.
  • Method Details

    • add

      @NonNull ImmutableSortedSet<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 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 @NonNull ImmutableSortedSet<E> addAll(@NonNull 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 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
    • empty

      <T> @NonNull ImmutableSortedSet<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 ImmutableSet<E>
      Type Parameters:
      T - the element type of the returned set
      Returns:
      an empty set of the specified element type.
    • empty

      <T> @NonNull ImmutableCollection<T> empty(@Nullable Comparator<T> comparator)
      Returns a copy of this collection that is empty, and has the specified type and comparator.
      Type Parameters:
      T - the element type of the collection
      Parameters:
      comparator - a comparator for ordering the elements of the set, specify null to use the natural order of the elements
      Returns:
      an empty collection of the specified type and comparator
    • remove

      @NonNull ImmutableSortedSet<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 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 @NonNull ImmutableSortedSet<E> removeAll(@NonNull 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 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 ImmutableSortedSet<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 ImmutableSortedSet<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

      default @NonNull ImmutableSortedSet<E> retainAll(@NonNull 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 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

      @NonNull NavigableSet<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.
    • reversed

      default @NonNull ImmutableSortedSet<E> reversed()