|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.rosuda.util.Node
public class Node
Implements the tree structure consisting of cascaded (unmarked) nodes. Each instance of Node represents a node.
| Field Summary | |
|---|---|
protected Vector |
ch
List of all child nodes (all of object type Node) |
protected int |
height
Height of the tree downwards (i.e. assuming this node is the root). |
protected int |
level
Depth (level) of this node. |
protected Node |
par
Parent node |
| Constructor Summary | |
|---|---|
Node()
constructs an empty, lonely node |
|
Node(Node t)
constructs a new root node as the parent of a subtree |
|
| Method Summary | |
|---|---|
void |
add(Node n)
adds a subtree as a child |
Node |
at(int pos)
returns the subnode (child) at specified index |
Enumeration |
children()
returns children enumeration |
int |
count()
returns # of children |
void |
getAllNodes(Vector dstv)
fills specified vector with all nodes contained in the tree (from this node downward, including) in prefix order (i.e. this node is stored as first) |
Node[] |
getChildren()
returns a list of all children |
int |
getHeight()
returns the height of the tree from this node downwards |
int |
getLevel()
returns the level of this node (i.e. the distance from the root) |
void |
getNodesAtLevel(int dest,
Vector nodes)
fills provided vector with all nodes at specified level (works downwards only, so makes sense basically only if used with roots) *experimental* |
int |
getNumNodes(boolean leavesOnly)
returns # of nodes in the tree from this node downwards (incl. current one). |
Node |
getParent()
returns parent node |
Node |
getRoot()
returns root if the tree |
boolean |
isLeaf()
checks whether this node is a leaf |
boolean |
isRoot()
checks whether this node is a root |
void |
prune()
prune this node from its parent. |
void |
rebuildHeight()
rebuilds tree height cache for this node and upwards (is called internally after updates. |
void |
rebuildLevels()
rebuilds levels cache for this node and all subnodes (is called internally after updates. |
void |
remove(Node l)
remove a node from current children. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Vector ch
Node)
protected Node par
protected int level
protected int height
| Constructor Detail |
|---|
public Node()
public Node(Node t)
t - subtree| Method Detail |
|---|
public boolean isLeaf()
true if this node is a leaf (i.e. has no children)public boolean isRoot()
true if this node is a root (i.e. has no parent)public Node[] getChildren()
Node objects or null if this node is a leafpublic int count()
public Node at(int pos)
pos - index of the subnode (child). First child is at index 0, last at count()-1. Returns null if range is invalid or node has no children.
Node objectpublic void add(Node n)
n - node (root of the subtree) to be addedpublic void prune()
public void remove(Node l)
l - child to be removedpublic Enumeration children()
Enumeration of children of null if leaf.public Node getParent()
null if this node is a root)
public void getNodesAtLevel(int dest,
Vector nodes)
dest - level of nodes to be addednodes - Vector to be used for storage of the nodes (as Node objects). This method does no sanity checks, so ensure your vector is validpublic Node getRoot()
this if the node is already the root)public int getLevel()
public int getHeight()
public void getAllNodes(Vector dstv)
dstv - destination vector. Objects of type Node are stored.
It's not cleared implicitely. Expect a null-exception if you pass null instead of a valid vector.public int getNumNodes(boolean leavesOnly)
leavesOnly - if set to true, only leaves are counted.
public void rebuildLevels()
public void rebuildHeight()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||