|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectUtil.Structures.NimbleTree<E>
public class NimbleTree<E>
Lightweight tree n-arity structure
Constructor Summary | |
---|---|
NimbleTree()
Creates a new instance of NimbleTree |
|
NimbleTree(E data)
Creates a new Tree with data as the root nodes data |
|
NimbleTree(NimbleTree<E> n)
Copy constructor |
Method Summary | |
---|---|
void |
addChild(E data)
Add a child to the current node. |
java.util.ArrayList<TreeNode<E>> |
depthFirstTraversal(TreeNode<E> root)
Do a depth-first traversal of the tree starting at a given node. |
java.util.ArrayList<TreeNode<E>> |
getAncestorChain(TreeNode<E> node,
int n)
Starting at a given node, get a chain of ancestors of length n or less. |
java.util.ArrayList<java.util.ArrayList<TreeNode<E>>> |
getAncestorChains(int n)
Get all the chains of ancestors of length n in this tree. |
java.util.ArrayList<java.lang.Integer> |
getBranchLengths()
Do a depth first traversal and return the list of branch depths |
java.util.ArrayList<java.lang.Integer> |
getBranchLengths(TreeNode<E> root)
|
int |
getCurrentLevel()
Get current level |
TreeNode<E> |
getCurrentNode()
Get current node |
int |
getDepth()
Get maximum depth of tree |
int |
getMaxStackSize()
Get max stack size |
int |
getNodeCount()
Get node count |
TreeNode<E> |
getRoot()
Get root of tree |
java.util.ArrayList<java.util.ArrayList<TreeNode<E>>> |
getRootToLeafPaths()
Find all the paths from root to leaves. |
static NimbleTree<java.lang.String> |
makeTreeOverStringFromSExpression(java.lang.String input)
A static constructor (is this the right term?) |
protected TreeNode<E> |
newNode()
|
void |
populateStack()
Create nodes and push to the stack |
void |
setCurrentLevel(int i)
Set current level |
void |
setCurrentNode(TreeNode<E> tn)
Set current node |
void |
setDepth(int i)
Set depth of tree |
void |
setMaxStackSize(int i)
Set max stack size |
void |
setNodeCount(int i)
Set node count |
void |
setRoot(TreeNode<E> tn)
Set tree root |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NimbleTree()
public NimbleTree(E data)
data
as the root nodes data
data
- The data/label for the root nodepublic NimbleTree(NimbleTree<E> n)
n
- copied treeMethod Detail |
---|
protected TreeNode<E> newNode()
public void setMaxStackSize(int i)
i
- max stack sizepublic int getMaxStackSize()
public void populateStack()
public TreeNode<E> getRoot()
public void setRoot(TreeNode<E> tn)
tn
- root of treepublic TreeNode<E> getCurrentNode()
public void setCurrentNode(TreeNode<E> tn)
tn
- node to be currentpublic int getNodeCount()
public void setNodeCount(int i)
i
- number to setpublic void setDepth(int i)
i
- depthpublic int getDepth()
public int getCurrentLevel()
public void setCurrentLevel(int i)
i
- level to setpublic static NimbleTree<java.lang.String> makeTreeOverStringFromSExpression(java.lang.String input)
public java.util.ArrayList<java.util.ArrayList<TreeNode<E>>> getRootToLeafPaths()
public java.util.ArrayList<java.util.ArrayList<TreeNode<E>>> getAncestorChains(int n)
public java.util.ArrayList<TreeNode<E>> getAncestorChain(TreeNode<E> node, int n)
public java.util.ArrayList<TreeNode<E>> depthFirstTraversal(TreeNode<E> root)
public java.util.ArrayList<java.lang.Integer> getBranchLengths()
public java.util.ArrayList<java.lang.Integer> getBranchLengths(TreeNode<E> root)
public void addChild(E data)
data
- data contained in the childpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |