public class AvlTreeSingleton<K> extends Object implements AvlTree<K>
Constructor and Description |
---|
AvlTreeSingleton(K key,
Comparator<K> comparator) |
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 AvlTreeSingleton(K key, Comparator<K> comparator)
public LinkedAvlNode<K> find(K key)
public LinkedAvlNode<K> findGreater(K key)
findGreater
in interface AvlTree<K>
key
- the keypublic LinkedAvlNode<K> findGreaterOrEqual(K key)
findGreaterOrEqual
in interface AvlTree<K>
key
- the keypublic LinkedAvlNode<K> findLess(K key)
public LinkedAvlNode<K> findLessOrEqual(K key)
findLessOrEqual
in interface AvlTree<K>
key
- the keypublic Comparator<K> getComparator()
getComparator
in interface AvlTree<K>
public LinkedAvlNode<K> getFirst()
public LinkedAvlNode<K> getLast()
public LinkedAvlNode<K> getRoot()
public int getSize()
public K insert(K key)
AvlTree
public boolean isEmpty()
AvlTree
public void printTree()
AvlTree
Copyright © 2003–2020 The Apache Software Foundation. All rights reserved.