Top Fields Constructors Methods
com.vladsch.flexmark.util.ast

public Class NodeIterator

extends Object
implements ReversiblePeekingIterator<Node>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator, com.vladsch.flexmark.util.collection.iteration.ReversibleIterator, java.util.Iterator
Imports
com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator, org.jetbrains.annotations.Nullable, java.util.NoSuchElementException, java.util.function.Consumer

Field Summary

Modifier and TypeField and Description
public static final ReversiblePeekingIterator<Node>
pack-priv final Node
pack-priv final Node
pack-priv Node
pack-priv Node
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
public
NodeIterator(Node
node from which to start the iteration and continue until all sibling nodes have been traversed
firstNode
)

public
NodeIterator(Node
node from which to start the iteration and continue until all sibling nodes have been traversed
firstNode
,
boolean
true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling
reversed
)

public
NodeIterator(Node
node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed
firstNode
,
Node
the last node to be traversed
lastNode
)

public
NodeIterator(Node
node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed
firstNode
,
Node
the last node to be traversed
lastNode
,
boolean
true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling
reversed
)

iterate nodes until null or last node is iterated over

Method Summary

Modifier and TypeMethod and Description
public void
forEachRemaining(Consumer<? super Node>
The action to be performed for each element
consumer
)

Overrides default java.util.Iterator.forEachRemaining.

Performs the given action for each remaining element until all elements have been processed or the action throws an exception.

public boolean

Returns:

true if there is a next node
hasNext
()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public boolean

Returns:

true if the iterator is a reversed iterator
isReversed
()

Implements com.vladsch.flexmark.util.collection.iteration.ReversibleIterator.isReversed.

public Node

Returns:

the next node for the iterator. If the iterator is not reversed then the previous node's next sibling is returned. If it is reversed the the previous node's previous sibling is returned.
next
()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public @Nullable Node

Returns:

the node which would be returned by a call to next() or null if there is no next node.
peek
()

Implements com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator.peek.

public void
remove()

Overrides default java.util.Iterator.remove.

Remove the last node returned by next()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTYback to summary
public static final ReversiblePeekingIterator<Node> EMPTY
firstNodeback to summary
pack-priv final Node firstNode
lastNodeback to summary
pack-priv final Node lastNode
nodeback to summary
pack-priv Node node
resultback to summary
pack-priv Node result
reversedback to summary
pack-priv final boolean reversed

Constructor Detail

NodeIteratorback to summary
public NodeIterator(Node firstNode)
Parameters
firstNode:Node

node from which to start the iteration and continue until all sibling nodes have been traversed

NodeIteratorback to summary
public NodeIterator(Node firstNode, boolean reversed)
Parameters
firstNode:Node

node from which to start the iteration and continue until all sibling nodes have been traversed

reversed:boolean

true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling

NodeIteratorback to summary
public NodeIterator(Node firstNode, Node lastNode)
Parameters
firstNode:Node

node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed

lastNode:Node

the last node to be traversed

NodeIteratorback to summary
public NodeIterator(Node firstNode, Node lastNode, boolean reversed)

iterate nodes until null or last node is iterated over

Parameters
firstNode:Node

node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed

lastNode:Node

the last node to be traversed

reversed:boolean

true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling

Method Detail

forEachRemainingback to summary
public void forEachRemaining(Consumer<? super Node> consumer)

Overrides default java.util.Iterator.forEachRemaining.

Doc from java.util.Iterator.forEachRemaining.

Performs the given action for each remaining element until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

The behavior of an iterator is unspecified if the action modifies the collection in any way (even by calling the remove method or other mutator methods of Iterator subtypes), unless an overriding class has specified a concurrent modification policy.

Subsequent behavior of an iterator is unspecified if the action throws an exception.

Parameters
consumer:Consumer<? super Node>

The action to be performed for each element

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if there is a next node

Annotations
@Override
isReversedback to summary
public boolean isReversed()

Implements com.vladsch.flexmark.util.collection.iteration.ReversibleIterator.isReversed.

Returns:boolean

true if the iterator is a reversed iterator

Annotations
@Override
nextback to summary
public Node next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Node

the next node for the iterator. If the iterator is not reversed then the previous node's next sibling is returned. If it is reversed the the previous node's previous sibling is returned.

Annotations
@Override
peekback to summary
public @Nullable Node peek()

Implements com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator.peek.

Returns:@Nullable Node

the node which would be returned by a call to next() or null if there is no next node.

Annotations
@Nullable
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Remove the last node returned by next()

Annotations
@Override