Class RestrictedValueSortedMap<K,V>

java.lang.Object
ghidra.generic.util.datastruct.RestrictedValueSortedMap<K,V>
Type Parameters:
K - the type of keys
V - the type of values
All Implemented Interfaces:
ValueSortedMap<K,V>

public class RestrictedValueSortedMap<K,V> extends Object implements ValueSortedMap<K,V>
A view of the value-sorted map for implementing subMapByValue(Object, boolean, Object, boolean), etc.
  • Constructor Details

    • RestrictedValueSortedMap

      protected RestrictedValueSortedMap(ValueSortedMap<K,V> wrapped, 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 Details

    • getLowestIndex

      protected int getLowestIndex()
    • getHighestIndexPlusOne

      protected int getHighestIndexPlusOne()
    • size

      public int size()
      Specified by:
      size in interface ValueSortedMap<K,V>
    • inBoundsOrNeg1

      protected int inBoundsOrNeg1(int index)
    • restrictedSize

      protected int restrictedSize()
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface ValueSortedMap<K,V>
    • restrictedIsEmpty

      protected boolean restrictedIsEmpty()
    • inBounds

      protected boolean inBounds(V val)
    • inBoundsOrNull

      protected V inBoundsOrNull(V val)
    • inBoundsOrNull

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

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface ValueSortedMap<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface ValueSortedMap<K,V>
    • get

      public V get(Object key)
      Specified by:
      get in interface ValueSortedMap<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface ValueSortedMap<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface ValueSortedMap<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface ValueSortedMap<K,V>
    • entrySet

      Specified by:
      entrySet in interface ValueSortedMap<K,V>
    • lowerEntryByValue

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

      Specified by:
      keySet in interface ValueSortedMap<K,V>
    • 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
    • values

      public SortedList<V> values()
      Specified by:
      values in interface ValueSortedMap<K,V>