|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.server.core.avltree.ArrayTree<K>
public class ArrayTree<K>
A data structure simulating a tree (ie, a sorted list of elements) using an array.
Constructor Summary | |
---|---|
ArrayTree(java.util.Comparator<K> comparator)
Creates a new instance of AVLTree. |
|
ArrayTree(java.util.Comparator<K> comparator,
K[] array)
Creates a new instance of AVLTree. |
Method Summary | |
---|---|
boolean |
contains(K key)
Tells if a key exist in the array. |
K |
find(K key)
Find an element in the array. |
K |
findGreater(K key)
Finds a key higher than the given key. |
K |
findGreaterOrEqual(K key)
Finds a key higher than the given key. |
K |
findLess(K key)
Finds a key which is lower than the given key. |
K |
findLessOrEqual(K key)
Finds a key chich is lower than the given key. |
K |
get(int position)
Get the element at a given position |
int |
getAfterPosition(K key)
Find the element position in the array, or the position of the closest greater element in the array. |
int |
getBeforePosition(K key)
Find the element position in the array, or the position of the closest greater element in the array. |
java.util.Comparator<K> |
getComparator()
|
K |
getFirst()
Get the first element in the tree. |
java.util.List<K> |
getKeys()
|
K |
getLast()
Get the last element in the tree. |
int |
getPosition(K key)
Find the element position in the array. |
K |
insert(K key)
Inserts a key. |
boolean |
isEmpty()
Tests if the tree is empty. |
void |
printTree()
Prints the contents of AVL tree in pretty format |
K |
remove(K key)
Removes a key present in the tree |
int |
size()
returns the number of nodes present in this tree. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ArrayTree(java.util.Comparator<K> comparator)
comparator
- the comparator to be used for comparing keyspublic ArrayTree(java.util.Comparator<K> comparator, K[] array)
comparator
- the comparator to be used for comparing keysMethod Detail |
---|
public java.util.Comparator<K> getComparator()
public K insert(K key)
key
- the item to be inserted, should not be null
public K remove(K key)
key
- the value to be removed
public boolean isEmpty()
public int size()
public java.util.List<K> getKeys()
public void printTree()
public K get(int position) throws java.lang.ArrayIndexOutOfBoundsException
position
- The position in the tree
java.lang.ArrayIndexOutOfBoundsException
- If the position is not within the array boundariespublic K getFirst()
public K getLast()
public K findGreater(K key)
key
- the key to find
public K findGreaterOrEqual(K key)
key
- the key
public K findLess(K key)
key
- the key
public K findLessOrEqual(K key)
key
- the key
public K find(K key)
key
- the key to find
public int getPosition(K key)
key
- the key to find
public int getAfterPosition(K key)
key
- the key to find
public int getBeforePosition(K key)
key
- the key to find
public boolean contains(K key)
key
- The key to look for
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |