Interface ReadOnlySortedMap<K,​V>

  • Type Parameters:
    K - the type of keys maintained by this map
    V - the type of mapped values
    All Superinterfaces:
    ReadOnlyMap<K,​V>, ReadOnlySequencedMap<K,​V>
    All Known Subinterfaces:
    ReadOnlyNavigableMap<K,​V>
    All Known Implementing Classes:
    ReadOnlyTreeMap

    public interface ReadOnlySortedMap<K,​V>
    extends ReadOnlySequencedMap<K,​V>
    This interface was originally copied from GitHub's Open-JDK Account. Though the original file has been modified, few changes have been applied to the Javadoc Commenting. Due to fact that that is a Java interface file, there were few method bodies with Source-Code to begin with - meaning this is largely a copy of Method-Signatures and Java-Doc Comments.

    Method and parameter names & types have not been modified whatsoever; but several methods had to be eliminated for not being Read-Only. This Source-File was copied from the original Open JDK-21 file of the same (or, rather, highly similar) Interface-Name. The original file may be viewed on the JDK-21 GitHub public (and, coincidentally, Read-Only) Source-Release archive for Java Package java.util.*

    The Original '.java' Source-File's Header-Copyright Information is included here: File Copyright. Within that Copyright Notice, it is suggested that a copy of the GNU Public License V2 also be included alongside.
    Immutable variant of Java Collections Framework interface java.util.SortedMap<K, V>. This interface contains all of the methods that the standard Java interface ReadOnlySortedMap contains - except those which would directly or indirectly modify / mutate the internal data-structure.


    • Method Detail

      • comparator

        🡇     🗕  🗗  🗖
        java.util.Comparator<? super Kcomparator()
        Returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.
        Returns:
        the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys
      • subMap

        🡅  🡇     🗕  🗗  🗖
        ReadOnlySortedMap<K,​VsubMap​(K fromKey,
                                            K toKey)
        Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned map is empty.) The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

        The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.
        Parameters:
        fromKey - low endpoint (inclusive) of the keys in the returned map
        toKey - high endpoint (exclusive) of the keys in the returned map
        Returns:
        a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive
        Throws:
        java.lang.ClassCastException - if fromKey and toKey cannot be compared to one another using this map's comparator (or, if the map has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception if fromKey or toKey cannot be compared to keys currently in the map.
        java.lang.NullPointerException - if fromKey or toKey is null and this map does not permit null keys
        java.lang.IllegalArgumentException - if fromKey is greater than toKey; or if this map itself has a restricted range, and fromKey or toKey lies outside the bounds of the range
      • headMap

        🡅  🡇     🗕  🗗  🗖
        ReadOnlySortedMap<K,​VheadMap​(K toKey)
        Returns a view of the portion of this map whose keys are strictly less than toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

        The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.
        Parameters:
        toKey - high endpoint (exclusive) of the keys in the returned map
        Returns:
        a view of the portion of this map whose keys are strictly less than toKey
        Throws:
        java.lang.ClassCastException - if toKey is not compatible with this map's comparator (or, if the map has no comparator, if toKey does not implement Comparable). Implementations may, but are not required to, throw this exception if toKey cannot be compared to keys currently in the map.
        java.lang.NullPointerException - if toKey is null and this map does not permit null keys
        java.lang.IllegalArgumentException - if this map itself has a restricted range, and toKey lies outside the bounds of the range
      • tailMap

        🡅  🡇     🗕  🗗  🗖
        ReadOnlySortedMap<K,​VtailMap​(K fromKey)
        Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

        The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.
        Parameters:
        fromKey - low endpoint (inclusive) of the keys in the returned map
        Returns:
        a view of the portion of this map whose keys are greater than or equal to fromKey
        Throws:
        java.lang.ClassCastException - if fromKey is not compatible with this map's comparator (or, if the map has no comparator, if fromKey does not implement Comparable). Implementations may, but are not required to, throw this exception if fromKey cannot be compared to keys currently in the map.
        java.lang.NullPointerException - if fromKey is null and this map does not permit null keys
        java.lang.IllegalArgumentException - if this map itself has a restricted range, and fromKey lies outside the bounds of the range
      • firstKey

        🡅  🡇     🗕  🗗  🗖
        K firstKey()
        Returns the first (lowest) key currently in this map.
        Returns:
        the first (lowest) key currently in this map
        Throws:
        NoSuchElementException - if this map is empty
      • lastKey

        🡅  🡇     🗕  🗗  🗖
        K lastKey()
        Returns the last (highest) key currently in this map.
        Returns:
        the last (highest) key currently in this map
        Throws:
        NoSuchElementException - if this map is empty
      • reversed

        🡅     🗕  🗗  🗖
        default ReadOnlySortedMap<K,​Vreversed()
        Returns a reverse-ordered view of this map. The encounter order of mappings in the returned view is the inverse of the encounter order of mappings in this map. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view.
        Specified by:
        reversed in interface ReadOnlySequencedMap<K,​V>
        Returns:
        a reverse-ordered view of this map, as a ReadOnlySortedMap
        Code:
        Exact Method Body:
         return JDKReverseOrderSortedMapView.of(this);