Interface ValueSortedMap<K,V>

Type Parameters:
K - the type of the keys
V - the type of the values
All Known Implementing Classes:
RestrictedValueSortedMap, TreeValueSortedMap

public interface ValueSortedMap<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 Details

    • put

      V put(K key, V value)
    • get

      V get(Object key)
    • remove

      V remove(K key)
    • entrySet

    • lowerEntryByValue

      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

      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

      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

      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
    • keySet

    • 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()
    • isEmpty

      boolean isEmpty()
    • containsKey

      boolean containsKey(Object key)
    • containsValue

      boolean containsValue(Object value)
    • size

      int size()
    • clear

      void clear()