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
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 the 
Map.  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 ClassesModifier and TypeClassDescriptionprotected static final classprotected static final classstatic classprotected static classprotected static final classprotected class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final Comparator<UnsignedInteger>protected final intprotected NavigableMap<UnsignedInteger,E> protected intprotected final RingQueue<SplayMap.SplayedEntry<E>>protected Set<Map.Entry<UnsignedInteger,E>> protected NavigableSet<UnsignedInteger>protected intprotected static final Comparator<UnsignedInteger>protected SplayMap.SplayedEntry<E>Root node which can be null if the tree has no elements (size == 0)protected intCurrent size of the splayed map tree.protected Collection<E>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Comparator<? super UnsignedInteger>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) protected voidentryAdded(SplayMap.SplayedEntry<E> newEntry) protected voidentryDeleted(SplayMap.SplayedEntry<E> deletedEntry) entrySet()booleanprotected static <V> SplayMap.ImmutableSplayMapEntry<V>export(SplayMap.SplayedEntry<V> entry) firstKey()floorKey(UnsignedInteger key) voidforEach(BiConsumer<? super UnsignedInteger, ? super E> action) voidget(int key) Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison.getOrDefault(int key, E defaultValue) Gets the value of the element stored in theMapwith the key (treated as an unsigned integer for comparison.getOrDefault(Object key, E defaultValue) inthashCode()headMap(UnsignedInteger toKey) headMap(UnsignedInteger toKey, boolean inclusive) higherKey(UnsignedInteger key) booleanisEmpty()keySet()lastKey()lowerKey(UnsignedInteger key) Puts the value into the in theMapat the entry specified by the given key (treated as an unsigned integer for comparison.put(UnsignedInteger key, E value) voidputAll(Map<? extends UnsignedInteger, ? extends E> source) 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.putIfAbsent(UnsignedInteger key, E value) 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.booleanRemoves the entry for the specified primitive int (treated as unsigned) key only if it is currently mapped to the specified value in theMap.booleanremove(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.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.booleanReplaces 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.replace(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>intsize()subMap(UnsignedInteger fromKey, boolean fromInclusive, UnsignedInteger toKey, boolean toInclusive) subMap(UnsignedInteger fromKey, UnsignedInteger toKey) tailMap(UnsignedInteger fromKey) tailMap(UnsignedInteger fromKey, boolean inclusive) values()Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, merge
- 
Field Details- 
COMPARATOR
- 
REVERSE_COMPARATOR
- 
DEFAULT_ENTRY_POOL_SIZEprotected final int DEFAULT_ENTRY_POOL_SIZE- See Also:
 
- 
entryPool
- 
entriesInExistenceprotected int entriesInExistence
- 
rootRoot node which can be null if the tree has no elements (size == 0)
- 
sizeprotected int sizeCurrent size of the splayed map tree.
- 
modCountprotected int modCount
- 
keySet
- 
values
- 
entrySet
- 
descendingMapView
 
- 
- 
Constructor Details- 
SplayMappublic SplayMap()
 
- 
- 
Method Details- 
sizepublic int size()- Specified by:
- sizein interface- Map<UnsignedInteger,- E> 
 
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Map<UnsignedInteger,- E> 
 
- 
getGets 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.
- 
getOrDefaultGets 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.
- 
putPuts 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.
- 
putIfAbsentIf 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.
 
- 
removeRemoves 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.
 
- 
removeRemoves 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.
 
- 
put- Specified by:
- putin interface- Map<UnsignedInteger,- E> 
 
- 
putIfAbsent- Specified by:
- putIfAbsentin interface- Map<UnsignedInteger,- E> 
 
- 
get- Specified by:
- getin interface- Map<UnsignedInteger,- E> 
 
- 
getOrDefault- Specified by:
- getOrDefaultin interface- Map<UnsignedInteger,- E> 
 
- 
remove- Specified by:
- removein interface- Map<UnsignedInteger,- E> 
 
- 
containsKey- Specified by:
- containsKeyin interface- Map<UnsignedInteger,- E> 
 
- 
clearpublic void clear()- Specified by:
- clearin interface- Map<UnsignedInteger,- E> 
 
- 
putAll- Specified by:
- putAllin interface- Map<UnsignedInteger,- E> 
 
- 
containsValue- Specified by:
- containsValuein interface- Map<UnsignedInteger,- E> 
 
- 
hashCodepublic int hashCode()
- 
equals
- 
keySet- Specified by:
- keySetin interface- Map<UnsignedInteger,- E> 
- Specified by:
- keySetin interface- SortedMap<UnsignedInteger,- E> 
 
- 
values- Specified by:
- valuesin interface- Map<UnsignedInteger,- E> 
- Specified by:
- valuesin interface- SortedMap<UnsignedInteger,- E> 
 
- 
entrySet- Specified by:
- entrySetin interface- Map<UnsignedInteger,- E> 
- Specified by:
- entrySetin interface- SortedMap<UnsignedInteger,- E> 
 
- 
forEach- Specified by:
- forEachin interface- Map<UnsignedInteger,- E> 
 
- 
forEachA 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.
 
- 
replaceAll- Specified by:
- replaceAllin interface- Map<UnsignedInteger,- E> 
 
- 
remove- Specified by:
- removein interface- Map<UnsignedInteger,- E> 
 
- 
removeRemoves 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
 
- 
replace- Specified by:
- replacein interface- Map<UnsignedInteger,- E> 
 
- 
replaceReplaces 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
 
- 
replace- Specified by:
- replacein interface- Map<UnsignedInteger,- E> 
 
- 
replaceReplaces 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
 
- 
entryAdded
- 
entryDeleted
- 
delete
- 
export
- 
reverseComparator
- 
comparator- Specified by:
- comparatorin interface- SortedMap<UnsignedInteger,- E> 
 
- 
firstKey- Specified by:
- firstKeyin interface- SortedMap<UnsignedInteger,- E> 
 
- 
lastKey- Specified by:
- lastKeyin interface- SortedMap<UnsignedInteger,- E> 
 
- 
firstEntry- Specified by:
- firstEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
lastEntry- Specified by:
- lastEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
pollFirstEntry- Specified by:
- pollFirstEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
pollLastEntry- Specified by:
- pollLastEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
lowerEntry- Specified by:
- lowerEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
lowerKey- Specified by:
- lowerKeyin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
higherEntry- Specified by:
- higherEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
higherKey- Specified by:
- higherKeyin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
floorEntry- Specified by:
- floorEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
floorKey- Specified by:
- floorKeyin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
ceilingEntry- Specified by:
- ceilingEntryin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
ceilingKey- Specified by:
- ceilingKeyin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
descendingMap- Specified by:
- descendingMapin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
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> 
 
- 
headMap- Specified by:
- headMapin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
tailMap- Specified by:
- tailMapin interface- NavigableMap<UnsignedInteger,- E> 
 
- 
subMap- Specified by:
- subMapin interface- NavigableMap<UnsignedInteger,- E> 
- Specified by:
- subMapin interface- SortedMap<UnsignedInteger,- E> 
 
- 
headMap- Specified by:
- headMapin interface- NavigableMap<UnsignedInteger,- E> 
- Specified by:
- headMapin interface- SortedMap<UnsignedInteger,- E> 
 
- 
tailMap- Specified by:
- tailMapin interface- NavigableMap<UnsignedInteger,- E> 
- Specified by:
- tailMapin interface- SortedMap<UnsignedInteger,- E> 
 
 
-