Class ImmutableTreeMap<K,​V>

    • Constructor Detail

      • ImmutableTreeMap

        public ImmutableTreeMap​(Map<K,​V> sortedMap)
        Parameters:
        sortedMap - Map<K,V>; the map to use for the immutable map.
      • ImmutableTreeMap

        public ImmutableTreeMap​(NavigableMap<K,​V> map,
                                Immutable copyOrWrap)
        Parameters:
        map - NavigableMap<K,V>; the map to use for the immutable map.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
      • ImmutableTreeMap

        public ImmutableTreeMap​(ImmutableAbstractMap<K,​V> immutableMap)
        Parameters:
        immutableMap - ImmutableAbstractMap<K,V>; the map to use for the immutable map.
      • ImmutableTreeMap

        public ImmutableTreeMap​(ImmutableTreeMap<K,​V> immutableTreeMap,
                                Immutable copyOrWrap)
        Parameters:
        immutableTreeMap - ImmutableTreeMap<K,V>; the map to use for the immutable map.
        copyOrWrap - COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collection
    • Method Detail

      • comparator

        public final Comparator<? super K> comparator()
        Returns the comparator used to order the keys in this immutable map, or null if this immutable map uses the natural ordering of its keys.
        Specified by:
        comparator in interface ImmutableSortedMap<K,​V>
        Returns:
        the comparator used to order the keys in this immutable map, or null if this immutable map uses the natural ordering of its keys
      • subMap

        public final ImmutableSortedMap<K,​V> subMap​(K fromKey,
                                                          K toKey)
        Returns a view of the portion of this immutable map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned immutable map is empty.)

        The result of this method is a new, immutable sorted map.

        Specified by:
        subMap in interface ImmutableSortedMap<K,​V>
        Parameters:
        fromKey - K; low endpoint (inclusive) of the returned immutable map
        toKey - K; high endpoint (exclusive) of the returned immutable map
        Returns:
        a new, immutable sorted map of the portion of this immutable map whose keys range from fromKey, inclusive, to toKey, exclusive
      • headMap

        public final ImmutableSortedMap<K,​V> headMap​(K toKey)
        Returns a view of the portion of this immutable map whose keys are strictly less than toKey. The returned immutable map is backed by this immutable map, so changes in the returned immutable map are reflected in this immutable map, and vice-versa. The returned immutable map supports all optional immutable map operations that this immutable map supports.

        The result of this method is a new, immutable sorted map.

        Specified by:
        headMap in interface ImmutableSortedMap<K,​V>
        Parameters:
        toKey - K; high endpoint (exclusive) of the returned immutable map
        Returns:
        a view of the portion of this immutable map whose keys are strictly less than toKey
      • tailMap

        public final ImmutableSortedMap<K,​V> tailMap​(K fromKey)
        Returns a view of the portion of this immutable map whose keys are greater than or equal to fromKey. The returned immutable map is backed by this immutable map, so changes in the returned immutable map are reflected in this immutable map, and vice-versa. The returned immutable map supports all optional immutable map operations that this immutable map supports.

        The result of this method is a new, immutable sorted map.

        Specified by:
        tailMap in interface ImmutableSortedMap<K,​V>
        Parameters:
        fromKey - K; low endpoint (inclusive) of the returned immutable map
        Returns:
        a view of the portion of this immutable map whose keys are greater than or equal to fromKey
      • firstKey

        public final K firstKey()
        Returns the first (lowest) key currently in this immutable map.
        Specified by:
        firstKey in interface ImmutableSortedMap<K,​V>
        Returns:
        the first (lowest) key currently in this immutable map
      • lastKey

        public final K lastKey()
        Returns the last (highest) key currently in this immutable map.
        Specified by:
        lastKey in interface ImmutableSortedMap<K,​V>
        Returns:
        the last (highest) key currently in this immutable map
      • lowerKey

        public final K lowerKey​(K key)
        Returns the greatest key in this immutable map strictly less than the given key, or null if there is no such key.
        Specified by:
        lowerKey in interface ImmutableNavigableMap<K,​V>
        Parameters:
        key - K; the value to match
        Returns:
        the greatest key less than e, or null if there is no such key
      • floorKey

        public final K floorKey​(K key)
        Returns the greatest key in this immutable map less than or equal to the given key, or null if there is no such key.
        Specified by:
        floorKey in interface ImmutableNavigableMap<K,​V>
        Parameters:
        key - K; the value to match
        Returns:
        the greatest key less than or equal to e, or null if there is no such key
      • ceilingKey

        public final K ceilingKey​(K key)
        Returns the least key in this immutable map greater than or equal to the given key, or null if there is no such key.
        Specified by:
        ceilingKey in interface ImmutableNavigableMap<K,​V>
        Parameters:
        key - K; the value to match
        Returns:
        the least key greater than or equal to e, or null if there is no such key
      • higherKey

        public final K higherKey​(K key)
        Returns the least key in this immutable map strictly greater than the given key, or null if there is no such key.
        Specified by:
        higherKey in interface ImmutableNavigableMap<K,​V>
        Parameters:
        key - K; the value to match
        Returns:
        the least key greater than e, or null if there is no such key
      • descendingMap

        public final ImmutableNavigableMap<K,​V> descendingMap()
        Returns a reverse order view of the keys contained in this immutable map.

        The returned immutable map has an ordering equivalent to Collections.reverseOrder(comparator()). The expression s.descendingMap().descendingMap() returns a view of s essentially equivalent to s.

        Specified by:
        descendingMap in interface ImmutableNavigableMap<K,​V>
        Returns:
        a reverse order view of this immutable map
      • subMap

        public final ImmutableNavigableMap<K,​V> subMap​(K fromKey,
                                                             boolean fromInclusive,
                                                             K toKey,
                                                             boolean toInclusive)
        Returns a view of the portion of this immutable map whose keys range from fromKey to toKey. If fromKey and toKey are equal, the returned immutable map is empty unless fromInclusive and toInclusive are both true.
        Specified by:
        subMap in interface ImmutableNavigableMap<K,​V>
        Parameters:
        fromKey - K; low endpoint of the returned immutable map
        fromInclusive - boolean; true if the low endpoint is to be included in the returned view
        toKey - K; high endpoint of the returned immutable map
        toInclusive - boolean; true if the high endpoint is to be included in the returned view
        Returns:
        a view of the portion of this immutable map whose keys range from fromKey, inclusive, to toKey, exclusive
      • headMap

        public final ImmutableNavigableMap<K,​V> headMap​(K toKey,
                                                              boolean inclusive)
        Returns a view of the portion of this immutable map whose keys are less than (or equal to, if inclusive is true) toKey.
        Specified by:
        headMap in interface ImmutableNavigableMap<K,​V>
        Parameters:
        toKey - K; high endpoint of the returned immutable map
        inclusive - boolean; true if the high endpoint is to be included in the returned view
        Returns:
        a view of the portion of this immutable map whose keys are less than (or equal to, if inclusive is true) toKey
      • tailMap

        public final ImmutableNavigableMap<K,​V> tailMap​(K fromKey,
                                                              boolean inclusive)
        Returns a view of the portion of this immutable map whose keys are greater than (or equal to, if inclusive is true) fromKey.
        Specified by:
        tailMap in interface ImmutableNavigableMap<K,​V>
        Parameters:
        fromKey - K; low endpoint of the returned immutable map
        inclusive - boolean; true if the low endpoint is to be included in the returned view
        Returns:
        a view of the portion of this immutable map whose keys are greater than or equal to fromKey
      • toString

        public final String toString()
        Force to redefine toString.
        Specified by:
        toString in interface ImmutableMap<K,​V>
        Overrides:
        toString in class Object
        Returns:
        String; a description of this immutable map