Package dsa.lab08.solutions
Class AVLTree<Key extends Comparable<Key>,Value>
java.lang.Object
dsa.lab07.solutions.BinarySearchTree<Key,Value>
dsa.lab08.solutions.AVLTree<Key,Value>
- Type Parameters:
Key- the key typeValue- the value type
- All Implemented Interfaces:
Container<MapItem<Key,,Value>> Map<Key,,Value> OrderedMap<Key,,Value> Iterable<MapItem<Key,Value>>
An AVL tree.
-
Nested Class Summary
Nested classes/interfaces inherited from class dsa.lab07.solutions.BinarySearchTree
BinarySearchTree.ItemIterator<Key extends Comparable<Key>,Value>, BinarySearchTree.Node<Key extends Comparable<Key>, Value> -
Field Summary
Fields inherited from class dsa.lab07.solutions.BinarySearchTree
root, size -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class dsa.lab07.solutions.BinarySearchTree
find, findNode, items, max, min, next, previous, reversed, size, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface dsa.lab04.base.Map
containsKey, containsValue, get, insert, valuesMethods inherited from interface dsa.lab05.base.OrderedMap
keys, reversedKeys
-
Constructor Details
-
AVLTree
public AVLTree()Construct an empty AVL tree. -
AVLTree
Construct an AVL tree containing the given items.- Parameters:
items- the items
-
AVLTree
Construct an AVL tree containing the given items.- Parameters:
items- the items
-
-
Method Details
-
insert
Description copied from interface:MapInsert the given item.If there's already an item with the same key, that item is replaced with this one.
This means that if the key was not already contained, the size is incremented, otherwise it isn't.
- Specified by:
insertin interfaceMap<Key extends Comparable<Key>,Value> - Overrides:
insertin classBinarySearchTree<Key extends Comparable<Key>,Value> - Parameters:
item- the item
-
remove
Description copied from interface:MapRemove and return the item with the given key.Decrements the size (assuming the item was actually in the map).
- Specified by:
removein interfaceMap<Key extends Comparable<Key>,Value> - Overrides:
removein classBinarySearchTree<Key extends Comparable<Key>,Value> - Parameters:
key- the item's key- Returns:
- the item
- Throws:
NoSuchElementException- ifkeyis not contained
-
_isHeightCacheCorrect
public boolean _isHeightCacheCorrect() -
_isAVLConditionSatisfied
public boolean _isAVLConditionSatisfied()
-