|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--dog.util.Tree
A utility class for manipulating objects in a tree structure.
This class provides a way to associate arbitrary objects with one another in a hierarchy.
| Constructor Summary | |
Tree()
Constructs an empty tree. |
|
Tree(int increment)
Constructs an empty tree with the specified capacity increment. |
|
| Method Summary | |
void |
add(java.lang.Object object)
Adds a root to the tree. |
void |
add(java.lang.Object[] objects)
Adds roots to the tree. |
void |
add(java.lang.Object parent,
java.lang.Object child)
Adds a child to the specified parent in the tree. |
void |
add(java.lang.Object parent,
java.lang.Object[] children)
Adds children to the specified parent in the tree. |
void |
clear()
Removes all objects from the tree. |
boolean |
contains(java.lang.Object object)
Indicates whether the specified object is contained in the tree. |
int |
getChildCount(java.lang.Object parent)
Returns the number of children of the specified object. |
java.lang.Object[] |
getChildren(java.lang.Object parent)
Returns an array of children of the specified object, or an empty array if the object is not a parent in the tree. |
int |
getDepth(java.lang.Object object)
Returns the depth of the specified object in the tree. |
java.lang.Object |
getParent(java.lang.Object child)
Returns the parent of the specified object, or null if the object is a root or not a child in the tree. |
int |
getRootCount()
Returns the number of roots in this tree. |
java.lang.Object[] |
getRoots()
Returns the roots in this tree. |
java.lang.Object[] |
getTree()
Returns all the objects in this tree in depth-first order. |
int |
getTreeCount()
Returns the number of objects in this tree. |
boolean |
hasChildren()
Indicates whether there are any children in this tree. |
static void |
printArray(java.lang.String name,
java.lang.Object[] array,
int count)
|
void |
printElements()
|
void |
remove(java.lang.Object object)
Removes the specified object and all its children from the tree. |
void |
remove(java.lang.Object[] objects)
Removes the specified objects and all their children from the tree. |
void |
removeChildren(java.lang.Object parent)
Recursively removes the specified object's children from the tree. |
void |
sort(ObjectCollator collator)
Sorts the objects in the tree according to the specified object collator. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Tree()
public Tree(int increment)
increment - the amount by which the capacity is increased when an array overflows.| Method Detail |
public java.lang.Object getParent(java.lang.Object child)
public java.lang.Object[] getChildren(java.lang.Object parent)
public int getChildCount(java.lang.Object parent)
public boolean contains(java.lang.Object object)
public void add(java.lang.Object object)
public void add(java.lang.Object[] objects)
public void add(java.lang.Object parent,
java.lang.Object child)
java.lang.IllegalArgumentException - if the parent does not exist in the tree or the child is the parent.
public void add(java.lang.Object parent,
java.lang.Object[] children)
java.lang.IllegalArgumentException - if the parent does not exist in the tree or one of the children is the parent.public void remove(java.lang.Object object)
public void remove(java.lang.Object[] objects)
NullPointerException - if an object does not exist in the tree.public void removeChildren(java.lang.Object parent)
NullPointerException - if the object does not exist in the tree.public void clear()
public int getDepth(java.lang.Object object)
public java.lang.Object[] getRoots()
public int getRootCount()
public java.lang.Object[] getTree()
public int getTreeCount()
public boolean hasChildren()
public void sort(ObjectCollator collator)
public static void printArray(java.lang.String name,
java.lang.Object[] array,
int count)
public void printElements()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||