org.apache.directory.server.core.avltree
Interface AvlTreeMap<K,V>

All Known Implementing Classes:
AvlTreeMapImpl

public interface AvlTreeMap<K,V>

An interface to the AVL tree based map. The implementations should hold a value(s) along with a key

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

Method Summary
 LinkedAvlMapNode<K,V> find(K key)
          Find a LinkedAvlMapNode with the given key value in the tree.
 LinkedAvlMapNode<K,V> find(K key, V value)
          Find a LinkedAvlMapNode with the given key and value in the tree.
 LinkedAvlMapNode<K,V> findGreater(K key)
          Finds a LinkedAvlMapNode whose key is higher than the given key.
 LinkedAvlMapNode<K,V> findGreaterOrEqual(K key)
          Finds a LinkedAvlMapNode whose key is higher than the given key.
 LinkedAvlMapNode<K,V> findLess(K key)
          Finds a LinkedAvlMapNode whose key is lower than the given key.
 LinkedAvlMapNode<K,V> findLessOrEqual(K key)
          Finds a LinkedAvlMapNode whose key is lower than the given key.
 LinkedAvlMapNode<K,V> getFirst()
           
 java.util.Comparator<K> getKeyComparator()
           
 java.util.List<K> getKeys()
           
 LinkedAvlMapNode<K,V> getLast()
           
 LinkedAvlMapNode<K,V> getRoot()
           
 int getSize()
          returns the number of nodes present in this tree.
 java.util.Comparator<V> getValueComparator()
           
 V insert(K key, V value)
          Inserts a LinkedAvlMapNode with the given key and value.
 boolean isDupsAllowed()
          tells if the duplicate keys are supported or not.
 boolean isEmpty()
          Tests if the tree is logically empty.
 void printTree()
          Prints the contents of AVL tree in pretty format
 SingletonOrOrderedSet<V> remove(K key)
          Removes a node associated with the given key The entire node will be removed irrespective of whether duplicate keys are enabled or not
 V remove(K key, V value)
          Removes the LinkedAvlMapNode present in the tree with the given key and value
 

Method Detail

getKeyComparator

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

getValueComparator

java.util.Comparator<V> getValueComparator()
Returns:
the value comparator associated with this tree

insert

V insert(K key,
         V value)
Inserts a LinkedAvlMapNode with the given key and value.

Parameters:
key - the item to be inserted
value - the value associated with the key
Returns:
the replaced value if any exists else null Note: Replaces a nodes value if duplicate keys are not allowed and the new value is not equal to the existing value.

remove

V remove(K key,
         V value)
Removes the LinkedAvlMapNode present in the tree with the given key and value

Parameters:
key - the key of the node to be removed
value - the value of the node
Returns:
the removed value, if any, or null if the key or value does not exist
Throws:
java.lang.IllegalArgumentException - if key or value is null

remove

SingletonOrOrderedSet<V> remove(K key)
Removes a node associated with the given key The entire node will be removed irrespective of whether duplicate keys are enabled or not

Parameters:
key - the key of the node to be removed
Returns:
a SingletonOrOrderedSet
Throws:
java.lang.IllegalArgumentException - if key is null

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

LinkedAvlMapNode<K,V> getRoot()
Returns:
the root element of this tree (i.e., 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

LinkedAvlMapNode<K,V> getFirst()
Returns:
The first element of this tree

getLast

LinkedAvlMapNode<K,V> getLast()
Returns:
The last element in this tree

findGreater

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

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

findGreaterOrEqual

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

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

findLess

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

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

findLessOrEqual

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

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

find

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

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

find

LinkedAvlMapNode<K,V> find(K key,
                           V value)
Find a LinkedAvlMapNode with the given key and value in the tree.

Parameters:
key - the key of the node
value - the value of the node
Returns:
LinkedAvlMapNode having the given key and value

isDupsAllowed

boolean isDupsAllowed()
tells if the duplicate keys are supported or not.

Returns:
true if duplicate keys are allowed, false otherwise


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