Package ghidra.generic.util.datastruct
Class DynamicValueSortedTreeMap<K,V>
- java.lang.Object
- 
- java.util.AbstractMap<K,V>
- 
- ghidra.generic.util.datastruct.DynamicValueSortedTreeMap<K,V>
 
 
- 
- Type Parameters:
- K- the type of the keys
- V- the type of the values
 - All Implemented Interfaces:
- java.util.Map<K,V>
 
 public class DynamicValueSortedTreeMap<K,V> extends java.util.AbstractMap<K,V>A map that is sorted by value. This is an implementation ofMapwhere entries are sorted by value, rather than by key. Such a tree may be useful as a priority queue where the cost of an entry may change over time. As such, the collections returned byentrySet(),keySet(), andvalues()all implementDeque. The order of the entries will be updated on any call to {@link #put(Object, Object))}, or a call toCollection.add(Object)on the entry set. Additionally, if the values are mutable objects, whose costs may change, there is anupdate(Object)method, which notifies the map that the given key may need to be repositioned. The associated collections also implement theListinterface, providing fairly efficient implementations ofList.get(int)andList.indexOf(Object). Sequential access is best performed viaCollection.iterator(), since this will use a linked list. The underlying implementation is currently an unbalanced binary tree whose nodes also comprise a doubly-linked list. Currently, it is not thread safe.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classDynamicValueSortedTreeMap.EntryListIteratorAn iterator of the entriesprotected classDynamicValueSortedTreeMap.KeyListIteratorAn iterator of the keysprotected classDynamicValueSortedTreeMap.NodeAn entry in the map.protected classDynamicValueSortedTreeMap.ValueListIteratorAn iterator of the valuesclassDynamicValueSortedTreeMap.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.classDynamicValueSortedTreeMap.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.classDynamicValueSortedTreeMap.ValueSortedTreeMapValuesA public view of the map as a list of values This view implementsListandDeque, 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.
 - 
Constructor SummaryConstructors Constructor Description DynamicValueSortedTreeMap()Construct a dynamic value-sorted tree map using the values' natural ordering If the values do not have a natural ordering, you will eventually encounter aClassCastException.DynamicValueSortedTreeMap(java.util.Comparator<V> comparator)Construct a dynamic value-sorted tree map using a custom comparator to order the values
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)DynamicValueSortedTreeMap.ValueSortedTreeMapEntrySetentrySet()protected static booleaneq(java.lang.Object o1, java.lang.Object o2)A convenience for null-safe comparisonVget(java.lang.Object key)booleanisEmpty()DynamicValueSortedTreeMap.ValueSortedTreeMapKeySetkeySet()Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)intsize()booleanupdate(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.DynamicValueSortedTreeMap.ValueSortedTreeMapValuesvalues()
 
- 
- 
- 
Constructor Detail- 
DynamicValueSortedTreeMappublic DynamicValueSortedTreeMap() Construct a dynamic value-sorted tree map using the values' natural ordering If the values do not have a natural ordering, you will eventually encounter aClassCastException. This condition is not checked at construction.
 - 
DynamicValueSortedTreeMappublic DynamicValueSortedTreeMap(java.util.Comparator<V> comparator) Construct a dynamic value-sorted tree map using a custom comparator to order the values- Parameters:
- comparator- the comparator, providing a total ordering of the values
 
 
- 
 - 
Method Detail- 
eqprotected static boolean eq(java.lang.Object o1, java.lang.Object o2)A convenience for null-safe comparison
 - 
clearpublic void clear() 
 - 
containsKeypublic boolean containsKey(java.lang.Object key) 
 - 
containsValuepublic boolean containsValue(java.lang.Object value) 
 - 
entrySetpublic DynamicValueSortedTreeMap.ValueSortedTreeMapEntrySet entrySet() - Specified by:
- entrySetin interface- java.util.Map<K,V>
- Specified by:
- entrySetin class- java.util.AbstractMap<K,V>
- See Also:
- DynamicValueSortedTreeMap.ValueSortedTreeMapEntrySet
 
 - 
getpublic V get(java.lang.Object key) 
 - 
isEmptypublic boolean isEmpty() 
 - 
keySetpublic DynamicValueSortedTreeMap.ValueSortedTreeMapKeySet keySet() - Specified by:
- keySetin interface- java.util.Map<K,V>
- Overrides:
- keySetin class- java.util.AbstractMap<K,V>
- See Also:
- DynamicValueSortedTreeMap.ValueSortedTreeMapKeySet
 
 - 
removepublic V remove(java.lang.Object key) 
 - 
sizepublic int size() 
 - 
updatepublic 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
 
 - 
valuespublic DynamicValueSortedTreeMap.ValueSortedTreeMapValues values() - Specified by:
- valuesin interface- java.util.Map<K,V>
- Overrides:
- valuesin class- java.util.AbstractMap<K,V>
- See Also:
- DynamicValueSortedTreeMap.ValueSortedTreeMapValues
 
 
- 
 
-