public class AvlTreeImpl<K> extends Object implements AvlTree<K>
Constructor and Description |
---|
AvlTreeImpl(Comparator<K> comparator)
Creates a new instance of AVLTree.
|
Modifier and Type | Method and Description |
---|---|
LinkedAvlNode<K> |
find(K key)
Find a LinkedAvlNode with the given key value in the tree.
|
LinkedAvlNode<K> |
findGreater(K key)
Finds a LinkedAvlNode whose key is higher than the given key.
|
LinkedAvlNode<K> |
findGreaterOrEqual(K key)
Finds a LinkedAvlNode whose key is higher than the given key.
|
LinkedAvlNode<K> |
findLess(K key)
Finds a LinkedAvlNode whose key is lower than the given key.
|
LinkedAvlNode<K> |
findLessOrEqual(K key)
Finds a LinkedAvlNode whose key is lower than the given key.
|
Comparator<K> |
getComparator() |
LinkedAvlNode<K> |
getFirst() |
List<K> |
getKeys() |
LinkedAvlNode<K> |
getLast() |
LinkedAvlNode<K> |
getRoot() |
int |
getSize()
returns the number of nodes present in this tree.
|
K |
insert(K key)
Inserts a LinkedAvlNode with the given key.
|
boolean |
isEmpty()
Tests if the tree is logically empty.
|
void |
printTree()
Prints the contents of AVL tree in pretty format
|
K |
remove(K key)
Removes the LinkedAvlNode present in the tree with the given key value
|
public AvlTreeImpl(Comparator<K> comparator)
comparator
- the comparator to be used for comparing keyspublic Comparator<K> getComparator()
getComparator
in interface AvlTree<K>
public K insert(K key)
AvlTree
public K remove(K key)
AvlTree
public boolean isEmpty()
AvlTree
public int getSize()
AvlTree
public LinkedAvlNode<K> getRoot()
public void printTree()
AvlTree
public LinkedAvlNode<K> getFirst()
public LinkedAvlNode<K> getLast()
public LinkedAvlNode<K> findGreater(K key)
AvlTree
findGreater
in interface AvlTree<K>
key
- the keypublic LinkedAvlNode<K> findGreaterOrEqual(K key)
AvlTree
findGreaterOrEqual
in interface AvlTree<K>
key
- the keypublic LinkedAvlNode<K> findLess(K key)
AvlTree
public LinkedAvlNode<K> findLessOrEqual(K key)
AvlTree
findLessOrEqual
in interface AvlTree<K>
key
- the keyCopyright © 2003–2020 The Apache Software Foundation. All rights reserved.