|
net.datastructures - version 5.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.LinkedBinaryTree<Entry<K,V>>
net.datastructures.BinarySearchTreeMap<K,V>
net.datastructures.AVLTreeMap<K,V>
public class AVLTreeMap<K,V>
AVLTree class - implements an AVL Tree by extending a binary search tree.
Nested Class Summary | |
---|---|
protected static class |
AVLTreeMap.AVLNode<K,V>
Nested class for the nodes of an AVL tree. |
Nested classes/interfaces inherited from class net.datastructures.BinarySearchTreeMap |
---|
BinarySearchTreeMap.BSTEntry<K,V> |
Field Summary |
---|
Fields inherited from class net.datastructures.BinarySearchTreeMap |
---|
actionPos, C, numEntries |
Fields inherited from class net.datastructures.LinkedBinaryTree |
---|
root, size |
Constructor Summary | |
---|---|
AVLTreeMap()
|
|
AVLTreeMap(Comparator<K> c)
|
Method Summary | |
---|---|
protected BTPosition<Entry<K,V>> |
createNode(Entry<K,V> element,
BTPosition<Entry<K,V>> parent,
BTPosition<Entry<K,V>> left,
BTPosition<Entry<K,V>> right)
Creates a new binary search tree node (overrides super's version). |
protected int |
height(Position<Entry<K,V>> p)
Returns the height of a node (call back to an AVLNode). |
protected boolean |
isBalanced(Position<Entry<K,V>> p)
Returns whether a node has balance factor between -1 and 1. |
V |
put(K k,
V v)
If there is an entry with the specified key, replaces the value of this entry with the specified value and returns the old value. |
protected void |
rebalance(Position<Entry<K,V>> zPos)
Rebalance method called by insert and remove. |
V |
remove(K k)
If there is an entry with the specified key, removes this entry and returns its value. |
protected void |
setHeight(Position<Entry<K,V>> p)
Sets the height of an internal node (call back to an AVLNode). |
protected Position<Entry<K,V>> |
tallerChild(Position<Entry<K,V>> p)
Return a child of p with height no smaller than that of the other child. |
Methods inherited from class net.datastructures.BinarySearchTreeMap |
---|
checkEntry, checkKey, entry, entrySet, get, insertAtExternal, isEmpty, key, keySet, removeExternal, replaceEntry, restructure, size, treeSearch, value, values |
Methods inherited from class net.datastructures.LinkedBinaryTree |
---|
addRoot, attach, checkPosition, children, expandExternal, hasLeft, hasRight, inorderPositions, insertLeft, insertRight, isExternal, isInternal, isRoot, iterator, left, parent, positions, preorderPositions, remove, removeAboveExternal, replace, right, root, sibling, swapElements |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.datastructures.Map |
---|
entrySet, get, isEmpty, keySet, size, values |
Constructor Detail |
---|
public AVLTreeMap(Comparator<K> c)
public AVLTreeMap()
Method Detail |
---|
protected BTPosition<Entry<K,V>> createNode(Entry<K,V> element, BTPosition<Entry<K,V>> parent, BTPosition<Entry<K,V>> left, BTPosition<Entry<K,V>> right)
createNode
in class LinkedBinaryTree<Entry<K,V>>
protected int height(Position<Entry<K,V>> p)
protected void setHeight(Position<Entry<K,V>> p)
protected boolean isBalanced(Position<Entry<K,V>> p)
protected Position<Entry<K,V>> tallerChild(Position<Entry<K,V>> p)
protected void rebalance(Position<Entry<K,V>> zPos)
public V put(K k, V v) throws InvalidKeyException
put
in interface Map<K,V>
put
in class BinarySearchTreeMap<K,V>
InvalidKeyException
public V remove(K k) throws InvalidKeyException
remove
in interface Map<K,V>
remove
in class BinarySearchTreeMap<K,V>
InvalidKeyException
|
net.datastructures - version 5.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |