Package ghidra.generic.util.datastruct
Class RestrictedValueSortedMap<K,V>
- java.lang.Object
-
- ghidra.generic.util.datastruct.RestrictedValueSortedMap<K,V>
-
- Type Parameters:
K- the type of keysV- the type of values
- All Implemented Interfaces:
ValueSortedMap<K,V>,java.util.Map<K,V>
public class RestrictedValueSortedMap<K,V> extends java.lang.Object implements ValueSortedMap<K,V>
A view of the value-sorted map for implementingsubMapByValue(Object, boolean, Object, boolean), etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRestrictedValueSortedMap.RestrictedEntryListIteratorA list iterator suitable forList.listIterator(), etc., on the entries of aRestrictedValueSortedMapclassRestrictedValueSortedMap.RestrictedKeyListIteratorA list iterator suitable forList.listIterator(), etc., on the keys of aRestrictedValueSortedMapclassRestrictedValueSortedMap.RestrictedSortedListA list view suitable forValueSortedMap.values()ofRestrictedValueSortedMapclassRestrictedValueSortedMap.RestrictedValueListIteratorA list iterator suitable forList.listIterator(), etc., on the values of aRestrictedValueSortedMapclassRestrictedValueSortedMap.RestrictedValueSortedMapEntryListA list view suitable forValueSortedMap.entrySet()ofRestrictedValueSortedMapclassRestrictedValueSortedMap.RestrictedValueSortedMapKeyListA list view suitable forValueSortedMap.keySet()ofRestrictedValueSortedMap-
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K extends java.lang.Object,V extends java.lang.Object>
-
Nested classes/interfaces inherited from interface ghidra.generic.util.datastruct.ValueSortedMap
ValueSortedMap.ValueSortedMapEntryList<K,V>, ValueSortedMap.ValueSortedMapKeyList<K>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRestrictedValueSortedMap(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
-
Method Summary
All Methods Instance Methods Concrete 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, ornullif there is no such value.voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object 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, ornullif there is no such value.Vget(java.lang.Object key)protected intgetHighestIndexPlusOne()protected intgetLowestIndex()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, ifinclusiveis 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, ornullif there is no such value.protected booleaninBounds(V val)protected intinBoundsOrNeg1(int index)protected java.util.Map.Entry<K,V>inBoundsOrNull(java.util.Map.Entry<K,V> ent)protected VinBoundsOrNull(V val)booleanisEmpty()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, ornullif there is no such value.Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)protected booleanrestrictedIsEmpty()protected intrestrictedSize()intsize()ValueSortedMap<K,V>subMapByValue(V fromValue, boolean fromInclusive, V toValue, boolean toInclusive)Returns a view of the portion of this map whose values range fromfromValuetotoValue.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, ifinclusiveis true)toValue.booleanupdate(K key)Notify the map of an external change to the cost of a key's associated valueSortedList<V>values()
-
-
-
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 restrictcomparator- the value comparatorhasFrom- true if there exists a lower boundfromValue- the lower bound, if presentfromInclusive- true to include the lower boundhasTo- true if there exists an upper boundtoValue- the upper bound, if presenttoInclusive- true to include the upper bound
-
-
Method Detail
-
getLowestIndex
protected int getLowestIndex()
-
getHighestIndexPlusOne
protected int getHighestIndexPlusOne()
-
inBoundsOrNeg1
protected int inBoundsOrNeg1(int index)
-
restrictedSize
protected int restrictedSize()
-
restrictedIsEmpty
protected boolean restrictedIsEmpty()
-
inBounds
protected boolean inBounds(V val)
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
entrySet
public ValueSortedMap.ValueSortedMapEntryList<K,V> entrySet()
-
lowerEntryByValue
public java.util.Map.Entry<K,V> lowerEntryByValue(V value)
Description copied from interface:ValueSortedMapReturns a key-value mapping associated with the greatest value strictly less than the given value, ornullif there is no such value.- Specified by:
lowerEntryByValuein interfaceValueSortedMap<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:ValueSortedMapReturns a key-value mapping associated with the greatest value less than or equal to the given value, ornullif there is no such value.- Specified by:
floorEntryByValuein interfaceValueSortedMap<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:ValueSortedMapReturns a key-value mapping associated with the least value greater than or equal to the given value, ornullif there is no such value.- Specified by:
ceilingEntryByValuein interfaceValueSortedMap<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:ValueSortedMapReturns a key-value mapping associated with the least value strictly greater than the given value, ornullif there is no such value.- Specified by:
higherEntryByValuein interfaceValueSortedMap<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:ValueSortedMapReturns a view of the portion of this map whose values range fromfromValuetotoValue. The returned map is an unmodifiable view.- Specified by:
subMapByValuein interfaceValueSortedMap<K,V>- Parameters:
fromValue- low endpoint of the values in the returned mapfromInclusive-trueif the low endpoint is to be included in the returned viewtoValue- high endpoint of the values in the returned maptoInclusive-trueif 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:ValueSortedMapReturns a view of the portion of this map whose values are less than (or equal to, ifinclusiveis true)toValue. The returned map is an unmodifiable view.- Specified by:
headMapByValuein interfaceValueSortedMap<K,V>- Parameters:
toValue- high endpoint of the values in the returned mapinclusive-trueif 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:ValueSortedMapReturns a view of the portion of this map whose values are greater than (or equal to, ifinclusiveis true)toValue. The returned map is an unmodifiable view.- Specified by:
tailMapByValuein interfaceValueSortedMap<K,V>- Parameters:
fromValue- low endpoint of the values in the returned mapinclusive-trueif the low endpoint is to be included in the returned view- Returns:
- the view
-
keySet
public ValueSortedMap.ValueSortedMapKeyList<K> keySet()
-
update
public boolean update(K key)
Description copied from interface:ValueSortedMapNotify the map of an external change to the cost of a key's associated valueThis 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:
updatein interfaceValueSortedMap<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()
-
-