net.sf.staccatocommons.iterators
Class PrependThriterator<A>

java.lang.Object
  extended by net.sf.staccatocommons.iterators.AbstractUnmodifiableIterator<A>
      extended by net.sf.staccatocommons.iterators.thriter.AbstractThriterator<A>
          extended by net.sf.staccatocommons.iterators.thriter.AdvanceThriterator<A>
              extended by net.sf.staccatocommons.iterators.PrependThriterator<A>
All Implemented Interfaces:
Iterator<A>, EmptyAware, Thriter<A>, Thriterator<A>
Direct Known Subclasses:
DelayedPrependIterator

public class PrependThriterator<A>
extends AdvanceThriterator<A>

Author:
flbulgarelli

Constructor Summary
PrependThriterator(A element, Iterator<? extends A> iterator)
          Creates a new PrependThriterator
PrependThriterator(A element, Thriter<? extends A> iterator)
          Creates a new PrependThriterator
PrependThriterator(A element, Thriterator<? extends A> iterator)
          Creates a new PrependThriterator
 
Method Summary
 void advanceNext()
          Advances to the thriter to the position of the next element.
 A current()
          Answers element at the current position of this Thriter.
 Thunk<A> delayedCurrent()
          Answers a Thunk that, when evaluated through Thunk.value(), will return the current element of this Thriter at the time of being Thriter.delayedCurrent() sent.
protected  Thunk<A> elementThunk()
           
protected  A elementValue()
           
 boolean hasNext()
          Answers if the thriter has more elements, that is, if sending Thriter.advanceNext() would not result in a NoSuchElementException
 String toString()
           
 
Methods inherited from class net.sf.staccatocommons.iterators.thriter.AdvanceThriterator
next
 
Methods inherited from class net.sf.staccatocommons.iterators.thriter.AbstractThriterator
delayedNext, isEmpty
 
Methods inherited from class net.sf.staccatocommons.iterators.AbstractUnmodifiableIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
remove
 

Constructor Detail

PrependThriterator

public PrependThriterator(A element,
                          Thriter<? extends A> iterator)
Creates a new PrependThriterator


PrependThriterator

public PrependThriterator(A element,
                          Iterator<? extends A> iterator)
Creates a new PrependThriterator


PrependThriterator

public PrependThriterator(A element,
                          Thriterator<? extends A> iterator)
Creates a new PrependThriterator

Method Detail

hasNext

public final boolean hasNext()
Description copied from interface: Thriter
Answers if the thriter has more elements, that is, if sending Thriter.advanceNext() would not result in a NoSuchElementException

Returns:
if the Thriter has more elements

advanceNext

public final void advanceNext()
                       throws NoSuchElementException
Description copied from interface: Thriter
Advances to the thriter to the position of the next element.

Throws:
NoSuchElementException - if there are no more elements

current

public final A current()
                throws NoSuchElementException
Description copied from interface: Thriter
Answers element at the current position of this Thriter. Result of this method if Thriter.advanceNext() was never evaluated before is undefined.

Returns:
the current element
Throws:
NoSuchElementException

elementValue

protected A elementValue()

elementThunk

protected Thunk<A> elementThunk()

delayedCurrent

public Thunk<A> delayedCurrent()
Description copied from interface: Thriter
Answers a Thunk that, when evaluated through Thunk.value(), will return the current element of this Thriter at the time of being Thriter.delayedCurrent() sent. This means, that the value of the returned thunk must must always equals, even if this Thriter was advanced later.

Specified by:
delayedCurrent in interface Thriter<A>
Overrides:
delayedCurrent in class AbstractThriterator<A>
Returns:
a Thunk tha provides Thriter.current() at the time of this message being sent.

toString

public String toString()
Overrides:
toString in class Object


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads