Class CollectionsExt.ImmutableSortedSet<E>

  • Type Parameters:
    E - the class of the elements of this list.
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, java.util.SortedSet<E>
    Enclosing class:
    CollectionsExt<E>

    public static final class CollectionsExt.ImmutableSortedSet<E>
    extends CollectionsExt.AbstractImmutableCollection<java.util.SortedSet<E>,​E>
    implements java.util.SortedSet<E>
    A sorted set which prevents being modified by throwing an exception for the modifying methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.SortedSet<E> set
      The enclosed sorted set containing the elements of this sorted set.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Comparator<? super E> comparator()  
      E first()  
      java.util.SortedSet<E> headSet​(E toElement)
      Returns a view of the portion of this set whose elements are strictly less than toElement.
      E last()  
      java.util.SortedSet<E> subSet​(E fromElement, E toElement)
      Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
      java.util.SortedSet<E> tailSet​(E fromElement)
      Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
      java.util.SortedSet<E> unrestricted()
      Returns the underlying set without the restrictions imposed by this CollectionsExt.ImmutableCollection.
      • Methods inherited from class java.util.AbstractCollection

        contains, containsAll, isEmpty, toArray, toArray
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
      • Methods inherited from interface java.util.SortedSet

        spliterator
    • Field Detail

      • set

        private final java.util.SortedSet<E> set
        The enclosed sorted set containing the elements of this sorted set.
    • Constructor Detail

      • ImmutableSortedSet

        ImmutableSortedSet​(java.util.SortedSet<E> set)
    • Method Detail

      • comparator

        public java.util.Comparator<? super E> comparator()
        Specified by:
        comparator in interface java.util.SortedSet<E>
      • first

        public E first()
        Specified by:
        first in interface java.util.SortedSet<E>
      • last

        public E last()
        Specified by:
        last in interface java.util.SortedSet<E>
      • headSet

        public java.util.SortedSet<E> headSet​(E toElement)
        Returns a view of the portion of this set whose elements are strictly less than toElement. For information on backing see subSet(Object, Object).
        Specified by:
        headSet in interface java.util.SortedSet<E>
      • subSet

        public java.util.SortedSet<E> subSet​(E fromElement,
                                             E toElement)
        Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports. In particular, changes of the allowed modifications (returned by CollectionsExt.AbstractImmutableCollection.allowedModifications()) of the returned set are reflected in this set, and vice-versa.
        Specified by:
        subSet in interface java.util.SortedSet<E>
      • tailSet

        public java.util.SortedSet<E> tailSet​(E fromElement)
        Returns a view of the portion of this set whose elements are greater than or equal to fromElement. For information on backing see subSet(Object, Object).
        Specified by:
        tailSet in interface java.util.SortedSet<E>