Class RestrictedValueSortedMap<K,​V>

    • Constructor Detail

      • RestrictedValueSortedMap

        protected RestrictedValueSortedMap​(ValueSortedMap<K,​V> wrapped,
                                           java.util.Comparator<V> comparator,
                                           boolean hasFrom,
                                           V fromValue,
                                           boolean fromInclusive,
                                           boolean hasTo,
                                           V toValue,
                                           boolean toInclusive)
        Construct a restricted view of a value-sorted map
        Parameters:
        wrapped - the value-sorted map to restrict
        comparator - the value comparator
        hasFrom - true if there exists a lower bound
        fromValue - the lower bound, if present
        fromInclusive - true to include the lower bound
        hasTo - true if there exists an upper bound
        toValue - the upper bound, if present
        toInclusive - true to include the upper bound
    • Method Detail

      • getLowestIndex

        protected int getLowestIndex()
      • getHighestIndexPlusOne

        protected int getHighestIndexPlusOne()
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
      • inBoundsOrNeg1

        protected int inBoundsOrNeg1​(int index)
      • restrictedSize

        protected int restrictedSize()
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
      • restrictedIsEmpty

        protected boolean restrictedIsEmpty()
      • inBounds

        protected boolean inBounds​(V val)
      • inBoundsOrNull

        protected V inBoundsOrNull​(V val)
      • inBoundsOrNull

        protected java.util.Map.Entry<K,​V> inBoundsOrNull​(java.util.Map.Entry<K,​V> ent)
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
      • lowerEntryByValue

        public java.util.Map.Entry<K,​V> lowerEntryByValue​(V value)
        Description copied from interface: ValueSortedMap
        Returns a key-value mapping associated with the greatest value strictly less than the given value, or null if there is no such value.
        Specified by:
        lowerEntryByValue in interface ValueSortedMap<K,​V>
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • floorEntryByValue

        public java.util.Map.Entry<K,​V> floorEntryByValue​(V value)
        Description copied from interface: ValueSortedMap
        Returns a key-value mapping associated with the greatest value less than or equal to the given value, or null if there is no such value.
        Specified by:
        floorEntryByValue in interface ValueSortedMap<K,​V>
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • ceilingEntryByValue

        public java.util.Map.Entry<K,​V> ceilingEntryByValue​(V value)
        Description copied from interface: ValueSortedMap
        Returns a key-value mapping associated with the least value greater than or equal to the given value, or null if there is no such value.
        Specified by:
        ceilingEntryByValue in interface ValueSortedMap<K,​V>
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • higherEntryByValue

        public java.util.Map.Entry<K,​V> higherEntryByValue​(V value)
        Description copied from interface: ValueSortedMap
        Returns a key-value mapping associated with the least value strictly greater than the given value, or null if there is no such value.
        Specified by:
        higherEntryByValue in interface ValueSortedMap<K,​V>
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • subMapByValue

        public ValueSortedMap<K,​V> subMapByValue​(V fromValue,
                                                       boolean fromInclusive,
                                                       V toValue,
                                                       boolean toInclusive)
        Description copied from interface: ValueSortedMap
        Returns a view of the portion of this map whose values range from fromValue to toValue. The returned map is an unmodifiable view.
        Specified by:
        subMapByValue in interface ValueSortedMap<K,​V>
        Parameters:
        fromValue - low endpoint of the values in the returned map
        fromInclusive - true if the low endpoint is to be included in the returned view
        toValue - high endpoint of the values in the returned map
        toInclusive - true if the high endpoint is to be included in the returned view
        Returns:
        the view
      • headMapByValue

        public ValueSortedMap<K,​V> headMapByValue​(V toValue,
                                                        boolean inclusive)
        Description copied from interface: ValueSortedMap
        Returns a view of the portion of this map whose values are less than (or equal to, if inclusive is true) toValue. The returned map is an unmodifiable view.
        Specified by:
        headMapByValue in interface ValueSortedMap<K,​V>
        Parameters:
        toValue - high endpoint of the values in the returned map
        inclusive - true if the high endpoint is to be included in the returned view
        Returns:
        the view
      • tailMapByValue

        public ValueSortedMap<K,​V> tailMapByValue​(V fromValue,
                                                        boolean inclusive)
        Description copied from interface: ValueSortedMap
        Returns a view of the portion of this map whose values are greater than (or equal to, if inclusive is true) toValue. The returned map is an unmodifiable view.
        Specified by:
        tailMapByValue in interface ValueSortedMap<K,​V>
        Parameters:
        fromValue - low endpoint of the values in the returned map
        inclusive - true if the low endpoint is to be included in the returned view
        Returns:
        the view
      • update

        public boolean update​(K key)
        Description copied from interface: ValueSortedMap
        Notify the map of an external change to the cost of a key's associated value

        This is meant to update the entry's position after a change in cost. The position may not necessarily change, however, if the cost did not change significantly.

        Specified by:
        update in interface ValueSortedMap<K,​V>
        Parameters:
        key - the key whose associated value has changed in cost
        Returns:
        true if the entry's position changed