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 class
RestrictedValueSortedMap.RestrictedEntryListIterator
A list iterator suitable forList.listIterator()
, etc., on the entries of aRestrictedValueSortedMap
class
RestrictedValueSortedMap.RestrictedKeyListIterator
A list iterator suitable forList.listIterator()
, etc., on the keys of aRestrictedValueSortedMap
class
RestrictedValueSortedMap.RestrictedSortedList
A list view suitable forValueSortedMap.values()
ofRestrictedValueSortedMap
class
RestrictedValueSortedMap.RestrictedValueListIterator
A list iterator suitable forList.listIterator()
, etc., on the values of aRestrictedValueSortedMap
class
RestrictedValueSortedMap.RestrictedValueSortedMapEntryList
A list view suitable forValueSortedMap.entrySet()
ofRestrictedValueSortedMap
class
RestrictedValueSortedMap.RestrictedValueSortedMapKeyList
A 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 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
-
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, ornull
if there is no such value.void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(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, ornull
if there is no such value.V
get(java.lang.Object key)
protected int
getHighestIndexPlusOne()
protected int
getLowestIndex()
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, ifinclusive
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, ornull
if there is no such value.protected boolean
inBounds(V val)
protected int
inBoundsOrNeg1(int index)
protected java.util.Map.Entry<K,V>
inBoundsOrNull(java.util.Map.Entry<K,V> ent)
protected V
inBoundsOrNull(V val)
boolean
isEmpty()
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, ornull
if there is no such value.V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> m)
V
remove(java.lang.Object key)
protected boolean
restrictedIsEmpty()
protected int
restrictedSize()
int
size()
ValueSortedMap<K,V>
subMapByValue(V fromValue, boolean fromInclusive, V toValue, boolean toInclusive)
Returns a view of the portion of this map whose values range fromfromValue
totoValue
.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, ifinclusive
is true)toValue
.boolean
update(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:ValueSortedMap
Returns a key-value mapping associated with the greatest value strictly less than the given value, ornull
if there is no such value.- Specified by:
lowerEntryByValue
in 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:ValueSortedMap
Returns a key-value mapping associated with the greatest value less than or equal to the given value, ornull
if there is no such value.- Specified by:
floorEntryByValue
in 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:ValueSortedMap
Returns a key-value mapping associated with the least value greater than or equal to the given value, ornull
if there is no such value.- Specified by:
ceilingEntryByValue
in 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:ValueSortedMap
Returns a key-value mapping associated with the least value strictly greater than the given value, ornull
if there is no such value.- Specified by:
higherEntryByValue
in 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:ValueSortedMap
Returns a view of the portion of this map whose values range fromfromValue
totoValue
. The returned map is an unmodifiable view.- Specified by:
subMapByValue
in interfaceValueSortedMap<K,V>
- Parameters:
fromValue
- low endpoint of the values in the returned mapfromInclusive
-true
if the low endpoint is to be included in the returned viewtoValue
- high endpoint of the values in the returned maptoInclusive
-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, ifinclusive
is true)toValue
. The returned map is an unmodifiable view.- Specified by:
headMapByValue
in interfaceValueSortedMap<K,V>
- Parameters:
toValue
- high endpoint of the values in the returned mapinclusive
-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, ifinclusive
is true)toValue
. The returned map is an unmodifiable view.- Specified by:
tailMapByValue
in interfaceValueSortedMap<K,V>
- Parameters:
fromValue
- low endpoint of the values in the returned mapinclusive
-true
if 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:ValueSortedMap
Notify 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:
update
in 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()
-
-