Package ghidra.generic.util.datastruct
Class TreeValueSortedMap<K,V>
- java.lang.Object
 - 
- java.util.AbstractMap<K,V>
 - 
- ghidra.generic.util.datastruct.TreeValueSortedMap<K,V>
 
 
 
- 
- Type Parameters:
 K- the type of the keysV- the type of the values
- All Implemented Interfaces:
 ValueSortedMap<K,V>,java.util.Map<K,V>
public class TreeValueSortedMap<K,V> extends java.util.AbstractMap<K,V> implements ValueSortedMap<K,V>
A tree-based implementation of a value-sorted map The underlying implementation is currently an unbalanced binary tree whose nodes also comprise a doubly-linked list. Currently, it is not thread safe. Note this implementation isn't terribly smart, as it makes no efforts to balance the tree. It is also not thread safe. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classTreeValueSortedMap.EntryListIteratorAn iterator of the entriesprotected classTreeValueSortedMap.KeyListIteratorAn iterator of the keysprotected classTreeValueSortedMap.NodeAn entry in the map.protected classTreeValueSortedMap.ValueListIteratorAn iterator of the valuesprotected classTreeValueSortedMap.ValueSortedTreeMapEntrySetA public view of the map as a set of entries In addition toSet, this view implementsListandDeque, since an ordered set ought to behave like a list, and since this implementation is meant to be used as a dynamic-cost priority queue.protected classTreeValueSortedMap.ValueSortedTreeMapKeySetA public view of the map as a set of keys In addition toSet, this view implementsListandDeque, since an ordered set ought to behave like a list, and since this implementation is meant to be used as a dynamic-cost priority queue.protected classTreeValueSortedMap.ValueSortedTreeMapValuesA public view of the map as a list of values This view implementsSortedListandDeque, since an ordered collection ought to behave like a list, and since this implementation is meant to be used as a dynamic-cost priority queue.- 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,V extends java.lang.Object> 
- 
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> 
 - 
 
- 
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<V>comparatorprotected TreeValueSortedMap.Nodeheadprotected java.util.Map<K,TreeValueSortedMap.Node>nodeMapprotected TreeValueSortedMap.Noderootprotected TreeValueSortedMap.Nodetail 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedTreeValueSortedMap()protectedTreeValueSortedMap(java.util.Comparator<V> comparator) 
- 
Method Summary
All Methods Static 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)protected TreeValueSortedMap.ValueSortedTreeMapEntrySetcreateEntrySet()protected TreeValueSortedMap.ValueSortedTreeMapKeySetcreateKeySet()protected TreeValueSortedMap.NodecreateNode(K key, V value)protected TreeValueSortedMap.ValueSortedTreeMapValuescreateValues()static <K,V>
TreeValueSortedMap<K,V>createWithComparator(java.util.Comparator<V> comparator)Create a tree using a custom comparator to order the valuesstatic <K,V extends java.lang.Comparable<V>>
TreeValueSortedMap<K,V>createWithNaturalOrder()Create a tree using the values' natural orderingTreeValueSortedMap.ValueSortedTreeMapEntrySetentrySet()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)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.booleanisEmpty()TreeValueSortedMap.ValueSortedTreeMapKeySetkeySet()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 TreeValueSortedMap.NodesearchValue(V value, ghidra.generic.util.datastruct.TreeValueSortedMap.SearchMode mode)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 valueTreeValueSortedMap.ValueSortedTreeMapValuesvalues() 
 - 
 
- 
- 
Field Detail
- 
comparator
protected final java.util.Comparator<V> comparator
 
- 
nodeMap
protected final java.util.Map<K,TreeValueSortedMap.Node> nodeMap
 
- 
root
protected TreeValueSortedMap.Node root
 
- 
head
protected TreeValueSortedMap.Node head
 
- 
tail
protected TreeValueSortedMap.Node tail
 
 - 
 
- 
Constructor Detail
- 
TreeValueSortedMap
protected TreeValueSortedMap()
 
- 
TreeValueSortedMap
protected TreeValueSortedMap(java.util.Comparator<V> comparator)
 
 - 
 
- 
Method Detail
- 
createWithNaturalOrder
public static <K,V extends java.lang.Comparable<V>> TreeValueSortedMap<K,V> createWithNaturalOrder()
Create a tree using the values' natural ordering 
- 
createWithComparator
public static <K,V> TreeValueSortedMap<K,V> createWithComparator(java.util.Comparator<V> comparator)
Create a tree using a custom comparator to order the values- Parameters:
 comparator- the comparator, providing a total ordering of the values
 
- 
createEntrySet
protected TreeValueSortedMap.ValueSortedTreeMapEntrySet createEntrySet()
 
- 
createKeySet
protected TreeValueSortedMap.ValueSortedTreeMapKeySet createKeySet()
 
- 
createValues
protected TreeValueSortedMap.ValueSortedTreeMapValues createValues()
 
- 
createNode
protected TreeValueSortedMap.Node createNode(K key, V value)
 
- 
searchValue
protected TreeValueSortedMap.Node searchValue(V value, ghidra.generic.util.datastruct.TreeValueSortedMap.SearchMode mode)
 
- 
clear
public void clear()
 
- 
containsKey
public boolean containsKey(java.lang.Object key)
 
- 
containsValue
public boolean containsValue(java.lang.Object value)
 
- 
entrySet
public TreeValueSortedMap.ValueSortedTreeMapEntrySet entrySet()
- Specified by:
 entrySetin interfacejava.util.Map<K,V>- Specified by:
 entrySetin interfaceValueSortedMap<K,V>- Specified by:
 entrySetin classjava.util.AbstractMap<K,V>- See Also:
 TreeValueSortedMap.ValueSortedTreeMapEntrySet
 
- 
get
public V get(java.lang.Object key)
 
- 
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 
 
- 
isEmpty
public boolean isEmpty()
 
- 
keySet
public TreeValueSortedMap.ValueSortedTreeMapKeySet keySet()
- Specified by:
 keySetin interfacejava.util.Map<K,V>- Specified by:
 keySetin interfaceValueSortedMap<K,V>- Overrides:
 keySetin classjava.util.AbstractMap<K,V>- See Also:
 TreeValueSortedMap.ValueSortedTreeMapKeySet
 
- 
remove
public V remove(java.lang.Object key)
 
- 
size
public int size()
 
- 
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 TreeValueSortedMap.ValueSortedTreeMapValues values()
- Specified by:
 valuesin interfacejava.util.Map<K,V>- Specified by:
 valuesin interfaceValueSortedMap<K,V>- Overrides:
 valuesin classjava.util.AbstractMap<K,V>- See Also:
 TreeValueSortedMap.ValueSortedTreeMapValues
 
- 
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
 
 
 - 
 
 -