Package com.zybooks.dsaj.searchtree
Class SplayTreeMap<K,V>
java.lang.Object
com.zybooks.dsaj.map.AbstractMap<K,V>
com.zybooks.dsaj.map.AbstractSortedMap<K,V>
com.zybooks.dsaj.searchtree.TreeMap<K,V>
com.zybooks.dsaj.searchtree.SplayTreeMap<K,V>
- Type Parameters:
K- The key type (keys must be unique and comparable)V- The value type
An implementation of a sorted map using a splay tree.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.zybooks.dsaj.searchtree.TreeMap
TreeMap.BalanceableBinaryTree<K,V> Nested classes/interfaces inherited from class com.zybooks.dsaj.map.AbstractMap
AbstractMap.MapEntry<K,V> -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty map using the natural ordering of keys.SplayTreeMap(Comparator<K> comp) Constructs an empty map using the given comparator to order keys. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidrebalanceAccess(Position<Entry<K, V>> p) Overrides the TreeMap rebalancing hook that is called after a node access.protected voidrebalanceDelete(Position<Entry<K, V>> p) Overrides the TreeMap rebalancing hook that is called after a deletion.protected voidrebalanceInsert(Position<Entry<K, V>> p) Overrides the TreeMap rebalancing hook that is called after an insertion.Methods inherited from class com.zybooks.dsaj.searchtree.TreeMap
ceilingEntry, dump, entrySet, firstEntry, floorEntry, get, higherEntry, isExternal, isInternal, isRoot, lastEntry, left, lowerEntry, oneSidedAncestor, parent, put, remove, restructure, right, root, rotate, set, sibling, size, subMap, treeMax, treeMinMethods inherited from class com.zybooks.dsaj.map.AbstractSortedMap
compare, compare, compare, compareMethods inherited from class com.zybooks.dsaj.map.AbstractMap
isEmpty, keySet, values
-
Constructor Details
-
SplayTreeMap
public SplayTreeMap()Constructs an empty map using the natural ordering of keys. -
SplayTreeMap
Constructs an empty map using the given comparator to order keys.- Parameters:
comp- comparator defining the order of keys in the map
-
-
Method Details
-
rebalanceAccess
Overrides the TreeMap rebalancing hook that is called after a node access.- Overrides:
rebalanceAccessin classTreeMap<K,V> - Parameters:
p- the Position which was recently accessed (possibly a leaf)
-
rebalanceInsert
Overrides the TreeMap rebalancing hook that is called after an insertion.- Overrides:
rebalanceInsertin classTreeMap<K,V> - Parameters:
p- the position which was recently inserted
-
rebalanceDelete
Overrides the TreeMap rebalancing hook that is called after a deletion.- Overrides:
rebalanceDeletein classTreeMap<K,V> - Parameters:
p- the position of the sibling of the removed leaf
-