Class 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.
    • 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.
      • children

        private final List<AptedNode<D>> children
        Array of pointers to this node's children. The order of children is significant due to the definition of ordered trees.
    • 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 StringNodeData due to using .

        Overrides:
        toString in class Object
        Returns:
        tree in bracket notation.
      • 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).
      • getChildren

        public List<AptedNode<D>> getChildren()
        Returns the list with all node's children.
        Returns:
        children of the node.