Class SplayMap<E>
- java.lang.Object
- 
- org.apache.qpid.protonj2.engine.util.SplayMap<E>
 
- 
- Type Parameters:
- E- The type stored in the map entries
 - All Implemented Interfaces:
- Map<UnsignedInteger,E>,- NavigableMap<UnsignedInteger,E>,- SortedMap<UnsignedInteger,E>
 - Direct Known Subclasses:
- LinkedSplayMap
 
 public class SplayMap<E> extends Object implements NavigableMap<UnsignedInteger,E> Map class that is implemented using a Splay Tree and uses primitive integers as the keys for the specified value type. The splay tree is a specialized form of a binary search tree that is self balancing and provides faster access in general to frequently used items. The splay tree serves well as an LRU cache of sorts where 80 percent of the accessed elements comes from 20 percent of the overall load in theMap. The best case access time is generally O(long n) however it can be Theta(n) in a very worst case scenario.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classSplayMap.AscendingSubMap<V>protected static classSplayMap.DescendingSubMap<V>static classSplayMap.ImmutableSplayMapEntry<E>protected static classSplayMap.NavigableSubMapKeySetprotected static classSplayMap.SplayedEntry<E>protected classSplayMap.SplayMapKeySet
 - 
Field SummaryFields Modifier and Type Field Description protected static Comparator<UnsignedInteger>COMPARATORprotected intDEFAULT_ENTRY_POOL_SIZEprotected NavigableMap<UnsignedInteger,E>descendingMapViewprotected intentriesInExistenceprotected RingQueue<SplayMap.SplayedEntry<E>>entryPoolprotected Set<Map.Entry<UnsignedInteger,E>>entrySetprotected NavigableSet<UnsignedInteger>keySetprotected intmodCountprotected static Comparator<UnsignedInteger>REVERSE_COMPARATORprotected SplayMap.SplayedEntry<E>rootRoot node which can be null if the tree has no elements (size == 0)protected intsizeCurrent size of the splayed map tree.protected Collection<E>values
 - 
Constructor SummaryConstructors Constructor Description SplayMap()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SplayMap.ImmutableSplayMapEntry<E>ceilingEntry(UnsignedInteger key)UnsignedIntegerceilingKey(UnsignedInteger key)voidclear()Comparator<? super UnsignedInteger>comparator()booleancontainsKey(int key)Searches the map using the given primitive integer key value which will be treated internally as an unsigned value when comparing against keys in the mapping.booleancontainsKey(Object key)booleancontainsValue(Object value)protected voiddelete(SplayMap.SplayedEntry<E> node)NavigableSet<UnsignedInteger>descendingKeySet()NavigableMap<UnsignedInteger,E>descendingMap()protected voidentryAdded(SplayMap.SplayedEntry<E> newEntry)protected voidentryDeleted(SplayMap.SplayedEntry<E> deletedEntry)Set<Map.Entry<UnsignedInteger,E>>entrySet()booleanequals(Object o)protected static <V> SplayMap.ImmutableSplayMapEntry<V>export(SplayMap.SplayedEntry<V> entry)SplayMap.ImmutableSplayMapEntry<E>firstEntry()UnsignedIntegerfirstKey()SplayMap.ImmutableSplayMapEntry<E>floorEntry(UnsignedInteger key)UnsignedIntegerfloorKey(UnsignedInteger key)voidforEach(BiConsumer<? super UnsignedInteger,? super E> action)voidforEach(Consumer<? super E> action)Eget(int key)Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison.Eget(Object key)EgetOrDefault(int key, E defaultValue)Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison.EgetOrDefault(Object key, E defaultValue)inthashCode()SortedMap<UnsignedInteger,E>headMap(UnsignedInteger toKey)NavigableMap<UnsignedInteger,E>headMap(UnsignedInteger toKey, boolean inclusive)SplayMap.ImmutableSplayMapEntry<E>higherEntry(UnsignedInteger key)UnsignedIntegerhigherKey(UnsignedInteger key)booleanisEmpty()Set<UnsignedInteger>keySet()SplayMap.ImmutableSplayMapEntry<E>lastEntry()UnsignedIntegerlastKey()SplayMap.ImmutableSplayMapEntry<E>lowerEntry(UnsignedInteger key)UnsignedIntegerlowerKey(UnsignedInteger key)NavigableSet<UnsignedInteger>navigableKeySet()SplayMap.ImmutableSplayMapEntry<E>pollFirstEntry()SplayMap.ImmutableSplayMapEntry<E>pollLastEntry()Eput(int key, E value)Puts the value into the in theMapat the entry specified by the given key (treated as an unsigned integer for comparison.Eput(UnsignedInteger key, E value)voidputAll(Map<? extends UnsignedInteger,? extends E> source)EputIfAbsent(int key, E value)If the specified key is not already associated with a value associates it with the given value and returns null, otherwise returns the current value.EputIfAbsent(UnsignedInteger key, E value)Eremove(int key)Removes the mapping for the primitiveintkey from this map if it is present and returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.booleanremove(int key, Object value)Removes the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the specified value in theMap.Eremove(Object key)booleanremove(Object key, Object value)Eremove(UnsignedInteger key)Removes the mapping for theUnsignedIntegerkey from this map if it is present and returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.Ereplace(int key, E value)Replaces the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the a value in theMapwith the new value provided.booleanreplace(int key, E oldValue, E newValue)Replaces the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the specified value in theMapwith the new value provided.Ereplace(UnsignedInteger key, E value)booleanreplace(UnsignedInteger key, E oldValue, E newValue)voidreplaceAll(BiFunction<? super UnsignedInteger,? super E,? extends E> function)protected static Comparator<? super UnsignedInteger>reverseComparator()intsize()NavigableMap<UnsignedInteger,E>subMap(UnsignedInteger fromKey, boolean fromInclusive, UnsignedInteger toKey, boolean toInclusive)SortedMap<UnsignedInteger,E>subMap(UnsignedInteger fromKey, UnsignedInteger toKey)SortedMap<UnsignedInteger,E>tailMap(UnsignedInteger fromKey)NavigableMap<UnsignedInteger,E>tailMap(UnsignedInteger fromKey, boolean inclusive)Collection<E>values()- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, merge
 
- 
 
- 
- 
- 
Field Detail- 
COMPARATORprotected static final Comparator<UnsignedInteger> COMPARATOR 
 - 
REVERSE_COMPARATORprotected static final Comparator<UnsignedInteger> REVERSE_COMPARATOR 
 - 
DEFAULT_ENTRY_POOL_SIZEprotected final int DEFAULT_ENTRY_POOL_SIZE - See Also:
- Constant Field Values
 
 - 
entryPoolprotected final RingQueue<SplayMap.SplayedEntry<E>> entryPool 
 - 
entriesInExistenceprotected int entriesInExistence 
 - 
rootprotected SplayMap.SplayedEntry<E> root Root node which can be null if the tree has no elements (size == 0)
 - 
sizeprotected int size Current size of the splayed map tree.
 - 
modCountprotected int modCount 
 - 
keySetprotected NavigableSet<UnsignedInteger> keySet 
 - 
valuesprotected Collection<E> values 
 - 
entrySetprotected Set<Map.Entry<UnsignedInteger,E>> entrySet 
 - 
descendingMapViewprotected NavigableMap<UnsignedInteger,E> descendingMapView 
 
- 
 - 
Method Detail- 
sizepublic int size() - Specified by:
- sizein interface- Map<UnsignedInteger,E>
 
 - 
isEmptypublic boolean isEmpty() - Specified by:
- isEmptyin interface- Map<UnsignedInteger,E>
 
 - 
getpublic E get(int key) Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison. As a side effect of calling this method the tree that comprises the Map can be modified to bring up the found key or the last accessed key if the key given is not in theMap. For entries at the root of the tree that match the given search key the method returns immediately without modifying theMap.
 - 
getOrDefaultpublic E getOrDefault(int key, E defaultValue) Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison. As a side effect of calling this method the tree that comprises the Map can be modified to bring up the found key or the last accessed key if the key given is not in theMap. For entries at the root of the tree that match the given search key the method returns immediately without modifying theMap.
 - 
putpublic E put(int key, E value) Puts the value into the in theMapat the entry specified by the given key (treated as an unsigned integer for comparison. As a side effect of calling this method the tree that comprises the Map can be modified to bring up the found key or the last accessed key if the key given is not in theMap. For entries at the root of the tree that match the given search key the method returns immediately without modifying theMap.
 - 
putIfAbsentpublic E putIfAbsent(int key, E value) If the specified key is not already associated with a value associates it with the given value and returns null, otherwise returns the current value. As a side effect of calling this method the tree that comprises the Map can be modified to bring up the found key or the last accessed key if the key given is not in theMap. For entries at the root of the tree that match the given search key the method returns immediately without modifying theMap.- Parameters:
- key- the integer key value to search for and or insert in the- SplayMap.
- value- the value to assign to the entry accessed via the given key.
- Returns:
- the previous value associated with the given key or null if none was present.
 
 - 
removepublic E remove(UnsignedInteger key) Removes the mapping for theUnsignedIntegerkey from this map if it is present and returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.- Parameters:
- key- The- UnsignedIntegerkey whose value will be removed from the- SplayMap.
- Returns:
- the value that was removed if one was present in the Map.
 
 - 
removepublic E remove(int key) Removes the mapping for the primitiveintkey from this map if it is present and returns the value to which this map previously associated the key, or null if the map contained no mapping for the key. The integer value is treated as an unsigned int internally.- Parameters:
- key- The- UnsignedIntegerkey whose value will be removed from the- SplayMap.
- Returns:
- the value that was removed if one was present in the Map.
 
 - 
containsKeypublic boolean containsKey(int key) Searches the map using the given primitive integer key value which will be treated internally as an unsigned value when comparing against keys in the mapping.- Parameters:
- key- The key which will be searched for in this mapping.
- Returns:
- trueif the key mapping is found within this- Map.
 
 - 
putpublic E put(UnsignedInteger key, E value) - Specified by:
- putin interface- Map<UnsignedInteger,E>
 
 - 
putIfAbsentpublic E putIfAbsent(UnsignedInteger key, E value) - Specified by:
- putIfAbsentin interface- Map<UnsignedInteger,E>
 
 - 
getOrDefaultpublic E getOrDefault(Object key, E defaultValue) - Specified by:
- getOrDefaultin interface- Map<UnsignedInteger,E>
 
 - 
containsKeypublic boolean containsKey(Object key) - Specified by:
- containsKeyin interface- Map<UnsignedInteger,E>
 
 - 
clearpublic void clear() - Specified by:
- clearin interface- Map<UnsignedInteger,E>
 
 - 
putAllpublic void putAll(Map<? extends UnsignedInteger,? extends E> source) - Specified by:
- putAllin interface- Map<UnsignedInteger,E>
 
 - 
containsValuepublic boolean containsValue(Object value) - Specified by:
- containsValuein interface- Map<UnsignedInteger,E>
 
 - 
hashCodepublic int hashCode() 
 - 
equalspublic boolean equals(Object o) 
 - 
keySetpublic Set<UnsignedInteger> keySet() - Specified by:
- keySetin interface- Map<UnsignedInteger,E>
- Specified by:
- keySetin interface- SortedMap<UnsignedInteger,E>
 
 - 
valuespublic Collection<E> values() - Specified by:
- valuesin interface- Map<UnsignedInteger,E>
- Specified by:
- valuesin interface- SortedMap<UnsignedInteger,E>
 
 - 
entrySetpublic Set<Map.Entry<UnsignedInteger,E>> entrySet() - Specified by:
- entrySetin interface- Map<UnsignedInteger,E>
- Specified by:
- entrySetin interface- SortedMap<UnsignedInteger,E>
 
 - 
forEachpublic void forEach(BiConsumer<? super UnsignedInteger,? super E> action) - Specified by:
- forEachin interface- Map<UnsignedInteger,E>
 
 - 
forEachpublic void forEach(Consumer<? super E> action) A specialized forEach implementation that accepts aConsumerfunction that will be called for each value in theSplayMap. This method can save overhead as it does not need to box the primitive key values into an object for the call to the provided function. Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.)- Parameters:
- action- The action to be performed for each of the values in the- SplayMap.
 
 - 
replaceAllpublic void replaceAll(BiFunction<? super UnsignedInteger,? super E,? extends E> function) - Specified by:
- replaceAllin interface- Map<UnsignedInteger,E>
 
 - 
removepublic boolean remove(Object key, Object value) - Specified by:
- removein interface- Map<UnsignedInteger,E>
 
 - 
removepublic boolean remove(int key, Object value)Removes the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the specified value in theMap.- Parameters:
- key- The key whose value will be removed if matched.
- value- The value that must be contained in the mapping for the remove to be performed.
- Returns:
- trueif an entry was removed from the- Map
 
 - 
replacepublic boolean replace(UnsignedInteger key, E oldValue, E newValue) - Specified by:
- replacein interface- Map<UnsignedInteger,E>
 
 - 
replacepublic boolean replace(int key, E oldValue, E newValue)Replaces the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the specified value in theMapwith the new value provided.- Parameters:
- key- The key whose value will be removed if matched.
- oldValue- The old value that must be contained in the mapping for the replace to be performed.
- newValue- The value that will replace the old value mapped to the given key if one existed..
- Returns:
- trueif an entry was replaced in the- Map
 
 - 
replacepublic E replace(UnsignedInteger key, E value) - Specified by:
- replacein interface- Map<UnsignedInteger,E>
 
 - 
replacepublic E replace(int key, E value) Replaces the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the a value in theMapwith the new value provided.- Parameters:
- key- The key whose value will be removed if matched.
- value- The value that will replace the old value mapped to the given key if one existed..
- Returns:
- trueif an entry was replaced in the- Map
 
 - 
entryAddedprotected void entryAdded(SplayMap.SplayedEntry<E> newEntry) 
 - 
entryDeletedprotected void entryDeleted(SplayMap.SplayedEntry<E> deletedEntry) 
 - 
deleteprotected void delete(SplayMap.SplayedEntry<E> node) 
 - 
exportprotected static <V> SplayMap.ImmutableSplayMapEntry<V> export(SplayMap.SplayedEntry<V> entry) 
 - 
reverseComparatorprotected static Comparator<? super UnsignedInteger> reverseComparator() 
 - 
comparatorpublic Comparator<? super UnsignedInteger> comparator() - Specified by:
- comparatorin interface- SortedMap<UnsignedInteger,E>
 
 - 
firstKeypublic UnsignedInteger firstKey() - Specified by:
- firstKeyin interface- SortedMap<UnsignedInteger,E>
 
 - 
lastKeypublic UnsignedInteger lastKey() - Specified by:
- lastKeyin interface- SortedMap<UnsignedInteger,E>
 
 - 
firstEntrypublic SplayMap.ImmutableSplayMapEntry<E> firstEntry() - Specified by:
- firstEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
lastEntrypublic SplayMap.ImmutableSplayMapEntry<E> lastEntry() - Specified by:
- lastEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
pollFirstEntrypublic SplayMap.ImmutableSplayMapEntry<E> pollFirstEntry() - Specified by:
- pollFirstEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
pollLastEntrypublic SplayMap.ImmutableSplayMapEntry<E> pollLastEntry() - Specified by:
- pollLastEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
lowerEntrypublic SplayMap.ImmutableSplayMapEntry<E> lowerEntry(UnsignedInteger key) - Specified by:
- lowerEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
lowerKeypublic UnsignedInteger lowerKey(UnsignedInteger key) - Specified by:
- lowerKeyin interface- NavigableMap<UnsignedInteger,E>
 
 - 
higherEntrypublic SplayMap.ImmutableSplayMapEntry<E> higherEntry(UnsignedInteger key) - Specified by:
- higherEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
higherKeypublic UnsignedInteger higherKey(UnsignedInteger key) - Specified by:
- higherKeyin interface- NavigableMap<UnsignedInteger,E>
 
 - 
floorEntrypublic SplayMap.ImmutableSplayMapEntry<E> floorEntry(UnsignedInteger key) - Specified by:
- floorEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
floorKeypublic UnsignedInteger floorKey(UnsignedInteger key) - Specified by:
- floorKeyin interface- NavigableMap<UnsignedInteger,E>
 
 - 
ceilingEntrypublic SplayMap.ImmutableSplayMapEntry<E> ceilingEntry(UnsignedInteger key) - Specified by:
- ceilingEntryin interface- NavigableMap<UnsignedInteger,E>
 
 - 
ceilingKeypublic UnsignedInteger ceilingKey(UnsignedInteger key) - Specified by:
- ceilingKeyin interface- NavigableMap<UnsignedInteger,E>
 
 - 
descendingMappublic NavigableMap<UnsignedInteger,E> descendingMap() - Specified by:
- descendingMapin interface- NavigableMap<UnsignedInteger,E>
 
 - 
navigableKeySetpublic NavigableSet<UnsignedInteger> navigableKeySet() - Specified by:
- navigableKeySetin interface- NavigableMap<UnsignedInteger,E>
 
 - 
descendingKeySetpublic NavigableSet<UnsignedInteger> descendingKeySet() - Specified by:
- descendingKeySetin interface- NavigableMap<UnsignedInteger,E>
 
 - 
subMappublic NavigableMap<UnsignedInteger,E> subMap(UnsignedInteger fromKey, boolean fromInclusive, UnsignedInteger toKey, boolean toInclusive) - Specified by:
- subMapin interface- NavigableMap<UnsignedInteger,E>
 
 - 
headMappublic NavigableMap<UnsignedInteger,E> headMap(UnsignedInteger toKey, boolean inclusive) - Specified by:
- headMapin interface- NavigableMap<UnsignedInteger,E>
 
 - 
tailMappublic NavigableMap<UnsignedInteger,E> tailMap(UnsignedInteger fromKey, boolean inclusive) - Specified by:
- tailMapin interface- NavigableMap<UnsignedInteger,E>
 
 - 
subMappublic SortedMap<UnsignedInteger,E> subMap(UnsignedInteger fromKey, UnsignedInteger toKey) - Specified by:
- subMapin interface- NavigableMap<UnsignedInteger,E>
- Specified by:
- subMapin interface- SortedMap<UnsignedInteger,E>
 
 - 
headMappublic SortedMap<UnsignedInteger,E> headMap(UnsignedInteger toKey) - Specified by:
- headMapin interface- NavigableMap<UnsignedInteger,E>
- Specified by:
- headMapin interface- SortedMap<UnsignedInteger,E>
 
 - 
tailMappublic SortedMap<UnsignedInteger,E> tailMap(UnsignedInteger fromKey) - Specified by:
- tailMapin interface- NavigableMap<UnsignedInteger,E>
- Specified by:
- tailMapin interface- SortedMap<UnsignedInteger,E>
 
 
- 
 
-