Class AptedNode<D>
- java.lang.Object
-
- com.crawljax.stateabstractions.dom.apted.node.AptedNode<D>
-
- Type Parameters:
D- the type of node data (node label).
public class AptedNode<D> extends Object
This is a recursive representation of an ordered tree. Each node stores a list of pointers to its children. The order of children is significant and must be observed while implmeneting a custom input parser.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(AptedNode c)Adds a new child at the end of children list.List<AptedNode<D>>getChildren()Returns the list with all node's children.intgetNodeCount()Counts the number of nodes in a tree rooted at this node.DgetNodeData()Returns node data.voidsetNodeData(D nodeData)Sets the node data of this node.StringtoString()Returns a string representation of the tree in bracket notation.
-
-
-
Field Detail
-
nodeData
private D nodeData
Information associated to and stored at each node. This can be anything and depends on the application, for example, string label, key-value pair, list of values, etc.
-
-
Constructor Detail
-
AptedNode
public AptedNode(D nodeData)
Constructs a new node with the passed node data and an empty list of children.- Parameters:
nodeData- instance of node data (node label).
-
-
Method Detail
-
getNodeCount
public int getNodeCount()
Counts the number of nodes in a tree rooted at this node.This method runs in linear time in the tree size.
- Returns:
- number of nodes in the tree rooted at this node.
-
addChild
public void addChild(AptedNode c)
Adds a new child at the end of children list. The added child will be the last child of this node.- Parameters:
c- child node to add.
-
toString
public String toString()
Returns a string representation of the tree in bracket notation.IMPORTANT: Works only for nodes storing
StringNodeDatadue to using .
-
getNodeData
public D getNodeData()
Returns node data. Used especially for calculating rename cost.- Returns:
- node data (label of a node).
-
setNodeData
public void setNodeData(D nodeData)
Sets the node data of this node.- Parameters:
nodeData- instance of node data (node label).
-
-