|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
java.lang.Object | +--com.sas.collection.AVLTree
An AVL tree, named after Adelson-Velskii and Landis. An AVL Tree consists of a root AVLNode and a comparator which is used to add new items or to search for values.
| Field Summary | |
static String |
RB_KEY
|
| Constructor Summary | |
AVLTree()
|
|
AVLTree(Comparator comparator)
|
|
AVLTree(Comparator comparator,
boolean duplicatesAllowed)
|
|
| Method Summary | |
void |
add(Object object)
Add the object into a tree rooted at root, using the comparator. |
Object |
clone()
Clone this AVL tree node. |
boolean |
contains(Object object)
Test if an object exists in the tree. |
int |
count()
Return the number of nodes in the tree. |
AVLNode |
firstNode()
|
Object |
get(Object query)
Return the object in the tree which is equal to query |
Comparator |
getComparator()
Return the comparator used to compare items. |
Enumeration |
getItems()
Get an enumeration of the tree contents |
AVLNode.Cursor |
getItems(boolean backwards)
Get an enumeration of the tree contents. |
Enumeration |
getItems(int start,
int end)
Get an enumeration of the tree contents |
boolean |
isDuplicatesAllowed()
Return true if duplicate values may be added to the AVL tree. |
AVLNode |
lastNode()
|
boolean |
remove(Object object)
Remove an object from the tree. |
void |
removeAll()
Remove all items from the tree. |
AVLNode |
root()
|
void |
setComparator(Comparator newComparator)
Set the comparator. |
void |
setDuplicatesAllowed(boolean duplicatesAllowed)
Set the whether the tree allows duplicate values to be inserted. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String RB_KEY
| Constructor Detail |
public AVLTree()
public AVLTree(Comparator comparator)
public AVLTree(Comparator comparator,
boolean duplicatesAllowed)
| Method Detail |
public int count()
count in interface Countablepublic void setComparator(Comparator newComparator)
newComparator - the new comparator.public void removeAll()
public AVLNode root()
public AVLNode firstNode()
public AVLNode lastNode()
public Comparator getComparator()
public void setDuplicatesAllowed(boolean duplicatesAllowed)
duplicatesAllowed - if false, you cannot add an item
that already exists to an AVLTree.public boolean isDuplicatesAllowed()
public void add(Object object)
object - the object to add into the treeroot - the root node. This may be nullcomparator - the Comparator to use when comparing items.public boolean contains(Object object)
object - a value to search for. The tree's comparator
is used; the object will be the first parameter.public Object get(Object query)
query - a value to search for. The tree's comparator
is used; the query object will be the first parameter to
the comparator's compare method; the item in the tree will be the second parameter.public boolean remove(Object object)
object - a value to remove. The tree's comparator
is used; the object will be the first parameter.public Enumeration getItems()
getItems in interface Enumerablecom.sas.util.EnumerableEnumerable does not support
enumerations, the getItems() method returns null
(An empty Enumerable still returns a non-null
Enumeration, but the first call to
hasMoreElements()
returns false).
public Enumeration getItems(int start,
int end)
public AVLNode.Cursor getItems(boolean backwards)
backwards - if true, the enumeration
traverses the tree backwards, from the end to the beginning.
public Object clone()
throws CloneNotSupportedException
clone in interface PublicClonableclone in class ObjectAVLNode.clone()
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||