Package EDU.purdue.jtb.parser.syntaxtree
Class NodeListOptional
java.lang.Object
EDU.purdue.jtb.parser.syntaxtree.NodeListOptional
- All Implemented Interfaces:
INode
,INodeList
,Serializable
Represents an optional grammar list (*), e.g. ' ( A )* '.
The class stores the nodes list in an ArrayList.
The class stores the nodes list in an ArrayList.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes an empty list of nodes with a default first allocation.NodeListOptional
(int sz) Initializes an empty list of nodes with a given allocation.NodeListOptional
(int sz, INode firstNode) Initializes an empty list of nodes with a given allocation and adds a first node.NodeListOptional
(INode firstNode) Initializes an empty list of nodes with a default first allocation and adds a first node. -
Method Summary
Modifier and TypeMethodDescriptionint
accept
(IIntVisitor vis) Accepts aIIntVisitor
visitor with user return data.void
accept
(IVoidVisitor vis) Accepts aIVoidVisitor
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.elements()
Returns an iterator on the nodes list.boolean
present()
int
size()
Returns the number of nodes in the list.
-
Field Details
-
nodes
The list of nodes
-
-
Constructor Details
-
NodeListOptional
public NodeListOptional()Initializes an empty list of nodes with a default first allocation. -
NodeListOptional
public NodeListOptional(int sz) Initializes an empty list of nodes with a given allocation.- Parameters:
sz
- - the list size
-
NodeListOptional
Initializes an empty list of nodes with a default first allocation and adds a first node.- Parameters:
firstNode
- - the node to add
-
NodeListOptional
Initializes an empty list of nodes with a given allocation and adds a first node.- Parameters:
sz
- - the list sizefirstNode
- - the node to add
-
-
Method Details
-
addNode
Adds a node to the list of nodes, managing progressive allocation increments. -
elementAt
Gets the node in the list at a given position. -
elements
Returns an iterator on the nodes list. -
size
public int size()Returns the number of nodes in the list. -
present
public boolean present()- Returns:
- true if there is at least one node, false otherwise
-
accept
Accepts aIIntVisitor
visitor with user return data. -
accept
Accepts aIVoidVisitor
visitor} visitor with user return data.
-