Interface ValueSortedMap<K,​V>

  • Type Parameters:
    K - the type of the keys
    V - the type of the values
    All Superinterfaces:
    java.util.Map<K,​V>
    All Known Implementing Classes:
    RestrictedValueSortedMap, TreeValueSortedMap

    public interface ValueSortedMap<K,​V>
    extends java.util.Map<K,​V>
    A map that is sorted by value.

    This is an extension of Map where entries are sorted by value, rather than by key. Such a map may be useful as a priority queue where the cost of an entry may change over time. As such, the collections returned by entrySet(), keySet(), and values() all extend Deque. The order of the entries will be updated on any call to Map.put(Object, Object), or a call to Collection.add(Object) on the entry set. Additionally, if the values are mutable objects, whose order may change, there is an update(Object) method, which notifies the map that the given key may need to be repositioned. The associated collections also extend the List interface, providing fairly efficient implementations of List.get(int) and List.indexOf(Object). Sequential access is best performed via Collection.iterator(), since this will use a linked list.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map.Entry<K,​V> ceilingEntryByValue​(V value)
      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.
      ValueSortedMap.ValueSortedMapEntryList<K,​V> entrySet()  
      java.util.Map.Entry<K,​V> floorEntryByValue​(V value)
      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.
      ValueSortedMap<K,​V> headMapByValue​(V toValue, boolean inclusive)
      Returns a view of the portion of this map whose values are less than (or equal to, if inclusive is true) toValue.
      java.util.Map.Entry<K,​V> higherEntryByValue​(V value)
      Returns a key-value mapping associated with the least value strictly greater than the given value, or null if there is no such value.
      ValueSortedMap.ValueSortedMapKeyList<K> keySet()  
      java.util.Map.Entry<K,​V> lowerEntryByValue​(V value)
      Returns a key-value mapping associated with the greatest value strictly less than the given value, or null if there is no such value.
      ValueSortedMap<K,​V> subMapByValue​(V fromValue, boolean fromInclusive, V toValue, boolean toInclusive)
      Returns a view of the portion of this map whose values range from fromValue to toValue.
      ValueSortedMap<K,​V> tailMapByValue​(V fromValue, boolean inclusive)
      Returns a view of the portion of this map whose values are greater than (or equal to, if inclusive is true) toValue.
      boolean update​(K key)
      Notify the map of an external change to the cost of a key's associated value
      SortedList<V> values()  
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size
    • Method Detail

      • lowerEntryByValue

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

        java.util.Map.Entry<K,​V> floorEntryByValue​(V value)
        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.
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • ceilingEntryByValue

        java.util.Map.Entry<K,​V> ceilingEntryByValue​(V value)
        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.
        Parameters:
        value - the value
        Returns:
        the found entry, or null
      • higherEntryByValue

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

        ValueSortedMap<K,​V> subMapByValue​(V fromValue,
                                                boolean fromInclusive,
                                                V toValue,
                                                boolean toInclusive)
        Returns a view of the portion of this map whose values range from fromValue to toValue. The returned map is an unmodifiable view.
        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

        ValueSortedMap<K,​V> headMapByValue​(V toValue,
                                                 boolean inclusive)
        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.
        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

        ValueSortedMap<K,​V> tailMapByValue​(V fromValue,
                                                 boolean inclusive)
        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.
        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

        boolean update​(K key)
        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.

        Parameters:
        key - the key whose associated value has changed in cost
        Returns:
        true if the entry's position changed
      • values

        SortedList<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>