Package com.zybooks.dsaj.searchtree
Class RBTreeMap<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.RBTreeMap<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 red-black 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.RBTreeMap(Comparator<K> comp) Constructs an empty map using the given comparator to order keys. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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, rebalanceAccess, 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
-
RBTreeMap
public RBTreeMap()Constructs an empty map using the natural ordering of keys. -
RBTreeMap
Constructs an empty map using the given comparator to order keys.- Parameters:
comp- comparator defining the order of keys in the map
-
-
Method Details
-
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
-