public class List.NodeListIterator extends ASTNodeIterator
java.util.ListIterator
is exposed through this class.Modifier and Type | Field and Description |
---|---|
protected ListIterator |
I
An iterator into
list . |
children, index
Constructor and Description |
---|
NodeListIterator()
Initializes
I . |
Modifier and Type | Method and Description |
---|---|
void |
add(ASTNode n)
Inserts the specified node into the list.
|
boolean |
hasNext()
Returns
true if this list iterator has more elements when traversing the
list in the forward direction. |
boolean |
hasPrevious()
Returns
true if this list iterator has more elements when traversing the
list in the reverse direction. |
ASTNode |
next()
Returns the next AST node in the list.
|
int |
nextIndex()
Returns the index of the node that would be returned by a subsequent call to
next() . |
ASTNode |
previous()
Returns the previous element in the list.
|
int |
previousIndex()
Returns the index of the node that would be returned by a subsequent call to
previous() . |
void |
remove()
Removes from the list the last element that was returned by
next() or
previous . |
void |
reset()
Restarts the iterator.
|
void |
set(ASTNode n)
Replaces the last element returned by
next() or previous() with
the specified element. |
protected ListIterator I
list
.public void add(ASTNode n)
next()
, if any, and after the next
element that would be returned by previous()
, if any. (If the list contains
no elements, the new element becomes the sole element on the list.) The new element is
inserted before the implicit cursor: a subsequent call to next()
would be
unaffected, and a subsequent call to previous()
would return the new
element. (This call increases by one the value that would be returned by a call to
nextIndex
or previousIndex
.)n
- The node to add.public boolean hasNext()
true
if this list iterator has more elements when traversing the
list in the forward direction.hasNext
in class ASTNodeIterator
true
if this list iterator has more elements when traversing the
list in the forward direction.public boolean hasPrevious()
true
if this list iterator has more elements when traversing the
list in the reverse direction.true
if this list iterator has more elements when traversing the
list in the reverse direction.public ASTNode next()
previous()
to go back and
forth. (Note that alternating calls to next()
and previous()
will return the same element repeatedly.)next
in class ASTNodeIterator
public int nextIndex()
next()
. (Returns list size if the list iterator is at the end of the list.)next()
, or list size if list iterator is at end of list.public ASTNode previous()
public int previousIndex()
previous()
. (Returns -1 if the list iterator is at the beginning of the
list.)previous()
, or -1 if list iterator is at the beginning of the list.public void remove()
next()
or
previous
. This call can only be made once per call to next()
or
previous
. It can be made only if add(ASTNode)
has not been
called after the last call to next()
or previous
.public void reset()
reset
in class ASTNodeIterator
public void set(ASTNode n)
next()
or previous()
with
the specified element. This call can be made only if neither remove()
nor
add(ASTNode)
have been called after the last call to next()
or
previous()
.n
- The element with which to replace the last element returned by
next()
or previous()
.Copyright © 2016. All rights reserved.