Class NodeList

java.lang.Object
EDU.purdue.jtb.parser.syntaxtree.NodeList
All Implemented Interfaces:
INode, INodeList, Serializable

public class NodeList extends Object implements INodeList
Represents a grammar list (+), e.g. ' ( A )+ '.
The class stores the nodes list in an ArrayList.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The list of nodes

    Fields inherited from interface EDU.purdue.jtb.parser.syntaxtree.INode

    LS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes an empty list of nodes with a default first allocation.
    NodeList(int sz)
    Initializes an empty list of nodes with a given allocation.
    NodeList(int sz, INode firstNode)
    Initializes an empty list of nodes with a given allocation and adds a first node.
    NodeList(INode firstNode)
    Initializes an empty list of nodes with a default first allocation and adds a first node.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Accepts a IIntVisitor visitor with user return data.
    void
    Accepts a IVoidVisitor visitor} visitor with user return data.
    void
    Adds a node to the list of nodes, managing progressive allocation increments.
    elementAt(int i)
    Gets the node in the list at a given position.
    Returns an iterator on the nodes list.
    int
    Returns the number of nodes in the list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • NodeList

      public NodeList()
      Initializes an empty list of nodes with a default first allocation.
    • NodeList

      public NodeList(int sz)
      Initializes an empty list of nodes with a given allocation.
      Parameters:
      sz - - the list size
    • NodeList

      public NodeList(INode firstNode)
      Initializes an empty list of nodes with a default first allocation and adds a first node.
      Parameters:
      firstNode - - the node to add
    • NodeList

      public NodeList(int sz, INode firstNode)
      Initializes an empty list of nodes with a given allocation and adds a first node.
      Parameters:
      sz - - the list size
      firstNode - - the node to add
  • Method Details

    • addNode

      public void addNode(INode n)
      Adds a node to the list of nodes, managing progressive allocation increments.
      Specified by:
      addNode in interface INodeList
      Parameters:
      n - - the node to add
    • elementAt

      public INode elementAt(int i)
      Gets the node in the list at a given position.
      Specified by:
      elementAt in interface INodeList
      Parameters:
      i - - the node's position
      Returns:
      the node
    • elements

      public Iterator<INode> elements()
      Returns an iterator on the nodes list.
      Specified by:
      elements in interface INodeList
      Returns:
      the iterator
    • size

      public int size()
      Returns the number of nodes in the list.
      Specified by:
      size in interface INodeList
      Returns:
      the list size
    • accept

      public int accept(IIntVisitor vis)
      Accepts a IIntVisitor visitor with user return data.
      Specified by:
      accept in interface INode
      Parameters:
      vis - - the visitor
      Returns:
      the user Return data
    • accept

      public void accept(IVoidVisitor vis)
      Accepts a IVoidVisitor visitor} visitor with user return data.
      Specified by:
      accept in interface INode
      Parameters:
      vis - - the visitor