Tree Node for a type T.
| Constructor and description |
|---|
TreeNode
(T data)Constructs a TreeNode with 0 parents and 0 children. |
TreeNode
(T data, java.util.LinkedList<TreeNode<T>> parents)Constructs a TreeNode with parents and 0 children. |
TreeNode
(T data, TreeNode<T> parent)Constructs a TreeNode with 1 parent and 0 children. |
| Type | Name and description |
|---|---|
void |
addChild(TreeNode<T> child, boolean twoWayRelationship)Adds a child to the current node. |
void |
addParent(TreeNode<T> parent, boolean twoWayRelationship)Adds a parent to the current node. |
boolean |
equals(java.lang.Object other)Compares this node to another node. |
java.util.Set<TreeNode<T>> |
getAncestors()Get ancestors, depth first. |
int |
hashCode()Generates the hash code for this node. |
java.lang.String |
toString() |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Nodes children.
Node's data.
Nodes parents.
Constructs a TreeNode with 0 parents and 0 children.
data - data for TreeNodeConstructs a TreeNode with parents and 0 children. Sets this tree node as the child of all parents to make a dual sided relationship.
data - contents for TreeNodeparents - parents of the node-to-beConstructs a TreeNode with 1 parent and 0 children. Set this tree node as the parent's child to make a dual sided relationship.
data - contents for TreeNodeparents - parents of the node-to-be Adds a child to the current node.
If a two way relationship is desired, child references this node as a
parent, and parent has as reference to this child. true creates
this dual relationship, false creates a one sided relationship.
This comes in handy when a node depends on ancestors of the parent, the child needs to reference the ancestor as a parent, but the reverse would allow the node to be parsed far too early.
child - child to add to this nodetwoWayRelationship - create a dual sided (two way) relationship Adds a parent to the current node.
If a two way relationship is desired, this node references the parent and
the parent has a reference to this node as a child. true creates
this dual relationship, false creates a one sided relationship.
This comes in handy when a node depends on ancestors of the parent, the child needs to reference the ancestor as a parent, but the reverse would allow the node to be parsed far too early.
parent - parent to add to this nodetwoWayRelationship - create a dual sided (two way) relationshipCompares this node to another node. Need to compare children AND parents. But not delve into them. Just checking their size is sufficient. If they are traversed, it leads to an infinite loop in this comparison.
other - node to compare against this oneGet ancestors, depth first. Nodes could be duplicates depending on the ancestry path -- a set is necessary.
Generates the hash code for this node.
Groovy Documentation