|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectrepast.simphony.util.collections.NaryTree<T>
public class NaryTree<T>
A rooted tree where each node can have n number of children.
| Nested Class Summary | |
|---|---|
protected class |
NaryTree.ChildIterator<T>
|
protected class |
NaryTree.NodeComparator<T>
|
| Constructor Summary | |
|---|---|
NaryTree(T rootObj)
Creates a NaryTree with the specified object as the root |
|
| Method Summary | |
|---|---|
void |
addNode(T parent,
T child)
Adds the specified child to the tree as a child of the specified parent. |
boolean |
contains(T parent,
T child)
Checks if the tree contains the specified node with the specified parent. |
protected boolean |
containsChecker(repast.simphony.util.collections.NaryTree.Node<T> node,
T parent,
T child)
|
Collection<T> |
getChildren(T obj)
Gets the direct children of the specified node. |
T |
getRoot()
Gets the root of the tree. |
Collection<T> |
getSiblings(T obj)
Retrieves the siblings of the specified object in the tree. |
protected void |
preOrderTraveralsOfNodes(repast.simphony.util.collections.NaryTree.Node<T> node,
TreeVisitor<repast.simphony.util.collections.NaryTree.Node<T>> visitor)
|
void |
preOrderTraversal(TreeVisitor<T> visitor)
Traverse the tree in preOrder - depth first, processing parents before children - applying the visitor to the nodes. |
boolean |
removeNode(T obj)
Removes the specified object from the tree. |
void |
replaceNode(T oldObj,
T newObj)
Replaces the old object in the tree with the new one. |
int |
size()
Gets the number of nodes currently in the tree. |
void |
sortChildren(Comparator<T> comparator)
Sorts the children of each node w/r to each other according the specified comparator |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NaryTree(T rootObj)
rootObj - the root object| Method Detail |
|---|
public T getRoot()
getRoot in interface Tree<T>public Collection<T> getChildren(T obj)
getChildren in interface Tree<T>IllegalArgumentException - if the object is not currently in the tree.
public void addNode(T parent,
T child)
addNode in interface Tree<T>parent - the parent nodechild - the child node
IllegalArgumentException - if the parent is not currently in the tree.public Collection<T> getSiblings(T obj)
obj - the object whose siblings to get
public boolean removeNode(T obj)
#replaceNode(T, T) it.
removeNode in interface Tree<T>obj - the object to remove
public void replaceNode(T oldObj,
T newObj)
replaceNode in interface Tree<T>oldObj - the old object to replacenewObj - the new object
IllegalArgumentException - if the old object is not currently in the tree.public void sortChildren(Comparator<T> comparator)
sortChildren in interface Tree<T>comparator - the comparator used to sort the childrenpublic int size()
size in interface Tree<T>public void preOrderTraversal(TreeVisitor<T> visitor)
preOrderTraversal in interface Tree<T>visitor - the visitor to apply to the nodes
protected void preOrderTraveralsOfNodes(repast.simphony.util.collections.NaryTree.Node<T> node,
TreeVisitor<repast.simphony.util.collections.NaryTree.Node<T>> visitor)
protected boolean containsChecker(repast.simphony.util.collections.NaryTree.Node<T> node,
T parent,
T child)
public boolean contains(T parent,
T child)
contains in interface Tree<T>parent - the parent nodenode - the child of the parent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||