org.apache.directory.server.core.avltree
Interface AvlTree<K>

All Known Implementing Classes:
AvlTreeImpl, AvlTreeSingleton

public interface AvlTree<K>

The interface for an AVL Tree.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Method Summary
 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.
 java.util.Comparator<K> getComparator()
           
 LinkedAvlNode<K> getFirst()
           
 java.util.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
 

Method Detail

getComparator

java.util.Comparator<K> getComparator()
Returns:
the comparator associated with this tree

insert

K insert(K key)
Inserts a LinkedAvlNode with the given key.

Parameters:
key - the item to be inserted
Returns:
the replaced key if it already exists Note: Ignores if a node with the given key already exists.

remove

K remove(K key)
Removes the LinkedAvlNode present in the tree with the given key value

Parameters:
key - the value of the node to be removed
Returns:
the removed key, if any, or null if the key does not exist

isEmpty

boolean isEmpty()
Tests if the tree is logically empty.

Returns:
true if the tree is empty, false otherwise

getSize

int getSize()
returns the number of nodes present in this tree.

Returns:
the number of nodes present in this tree

getRoot

LinkedAvlNode<K> getRoot()
Returns:
the root element of this tree (ie, not the first, but the topmost element)

getKeys

java.util.List<K> getKeys()
Returns:
a list of the stored keys in this tree

printTree

void printTree()
Prints the contents of AVL tree in pretty format


getFirst

LinkedAvlNode<K> getFirst()
Returns:
The first element of this tree

getLast

LinkedAvlNode<K> getLast()
Returns:
The last element in this tree

findGreater

LinkedAvlNode<K> findGreater(K key)
Finds a LinkedAvlNode whose key is higher than the given key.

Parameters:
key - the key
Returns:
the LinkedAvlNode whose key is greater than the given key ,
null if there is no node with a higher key than the given key.

findGreaterOrEqual

LinkedAvlNode<K> findGreaterOrEqual(K key)
Finds a LinkedAvlNode whose key is higher than the given key.

Parameters:
key - the key
Returns:
the LinkedAvlNode whose key is greater than the given key ,
null if there is no node with a higher key than the given key.

findLess

LinkedAvlNode<K> findLess(K key)
Finds a LinkedAvlNode whose key is lower than the given key.

Parameters:
key - the key
Returns:
the LinkedAvlNode whose key is lower than the given key ,
null if there is no node with a lower key than the given key.

findLessOrEqual

LinkedAvlNode<K> findLessOrEqual(K key)
Finds a LinkedAvlNode whose key is lower than the given key.

Parameters:
key - the key
Returns:
the LinkedAvlNode whose key is lower than the given key ,
null if there is no node with a lower key than the given key.

find

LinkedAvlNode<K> find(K key)
Find a LinkedAvlNode with the given key value in the tree.

Parameters:
key - the key to find
Returns:
the list of traversed LinkedAvlNode.


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.