org.eclipse.xtext.nodemodel.impl
Class BasicNodeIterable

java.lang.Object
  extended by org.eclipse.xtext.nodemodel.impl.BasicNodeIterable
All Implemented Interfaces:
java.lang.Iterable<AbstractNode>, BidiIterable<AbstractNode>

public class BasicNodeIterable
extends java.lang.Object
implements BidiIterable<AbstractNode>

Author:
Sebastian Zarnekow - Initial contribution and API
This class is not intended to be subclassed by clients.
This class is not intended to be subclassed by clients.

Constructor Summary
protected BasicNodeIterable(AbstractNode startWith)
           
 
Method Summary
 BidiIterator<AbstractNode> iterator()
          Returns an iterator that can be used forwards and backwards.
 BidiIterable<AbstractNode> reverse()
          Returns a reverse version of this iterable that can be used forwards and backwards.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicNodeIterable

protected BasicNodeIterable(AbstractNode startWith)
Method Detail

iterator

public BidiIterator<AbstractNode> iterator()
Description copied from interface: BidiIterable
Returns an iterator that can be used forwards and backwards.

Specified by:
iterator in interface java.lang.Iterable<AbstractNode>
Specified by:
iterator in interface BidiIterable<AbstractNode>
Returns:
an iterator. Never returns null.

reverse

public BidiIterable<AbstractNode> reverse()
Description copied from interface: BidiIterable

Returns a reverse version of this iterable that can be used forwards and backwards. In other words, an iterator provided by the reverse iterable will delegate its hasNext() and next() invocations to BidiIterator.hasPrevious() and BidiIterator.previous() respectively.

This allows clients to iterate backwards by means of the enhanced for-loop:

 for(T t: iterable.reverse()) {
   // do something with t
 }
 

Specified by:
reverse in interface BidiIterable<AbstractNode>
Returns:
the reversed iterable. Never returns null.