Class RestrictedCollections.RestrictedSortedSet

    • Constructor Detail

      • RestrictedSortedSet

        public RestrictedSortedSet​(SortedSet set,
                                   Class clz)
        Constructor.
        Parameters:
        set - the underlying SortedSet
        clz - the class of objects that may be stored in the SortedSet
    • Method Detail

      • comparator

        public Comparator comparator()
        Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
        Specified by:
        comparator in interface SortedSet
        Returns:
        the comparator associated with this sorted set, or null if it uses its elements' natural ordering
      • subSet

        public SortedSet subSet​(Object fromElement,
                                Object toElement)
        Returns a view of the portion of this sorted set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned sorted set is empty.) The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations that this sorted set supports.

        Obeys the general contract of SortedSet.subSet.

        Specified by:
        subSet in interface SortedSet
        Parameters:
        fromElement - low endpoint (inclusive) of the subSet
        toElement - high endpoint (exclusive) of the subSet
        Returns:
        a view of the specified range within this sorted set
      • headSet

        public SortedSet headSet​(Object toElement)
        Returns a view of the portion of this sorted set whose elements are strictly less than toElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations.

        Obeys the general contract of SortedSet.headSet.

        Specified by:
        headSet in interface SortedSet
        Parameters:
        toElement - high endpoint (exclusive) of the headSet
        Returns:
        a view of the specified initial range of this sorted set
      • tailSet

        public SortedSet tailSet​(Object fromElement)
        Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement. The returned sorted set is backed by this sorted set, so changes in the returned sorted set are reflected in this sorted set, and vice-versa. The returned sorted set supports all optional set operations.

        Obeys the general contract of SortedSet.tailSet.

        Specified by:
        tailSet in interface SortedSet
        Parameters:
        fromElement - low endpoint (inclusive) of the tailSet
        Returns:
        a view of the specified final range of this sorted set
      • first

        public Object first()
        Returns the first (lowest) element currently in this sorted set.
        Specified by:
        first in interface SortedSet
        Returns:
        the first (lowest) element currently in this sorted set
        Throws:
        NoSuchElementException - sorted set is empty
      • last

        public Object last()
        Returns the last (highest) element currently in this sorted set.
        Specified by:
        last in interface SortedSet
        Returns:
        the last (highest) element currently in this sorted set
        Throws:
        NoSuchElementException - sorted set is empty