net.sf.jga.fn.algorithm
Class LookAheadFunctor<T>

java.lang.Object
  extended by net.sf.jga.fn.UnaryFunctor<java.util.Iterator<? extends T>,LookAheadIterator<T>>
      extended by net.sf.jga.fn.algorithm.LookAheadFunctor<T>
All Implemented Interfaces:
java.io.Serializable, Visitable
Direct Known Subclasses:
FindAdjacent, FindMismatch, FindRepeated, FindSequence

public abstract class LookAheadFunctor<T>
extends UnaryFunctor<java.util.Iterator<? extends T>,LookAheadIterator<T>>

Abstract base class for functors that take an input iterator and return a LookAheadIterator. This class provides the ability to prevent excessive iterator wrapping by tracking the identity of the functor that has produced the wrapped iterator, and not re-wrapping an iterator if it was produced by the same object that is currently requesting a wrapped iterator.

Copyright © 2004 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Constructor Summary
LookAheadFunctor()
           
 
Method Summary
protected  LookAheadIterator<T> wrap(java.util.Iterator<? extends T> iterator, int count)
          Conditionally wraps the input iterator in a LookAheadIterator for return.
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
accept, bind, compose, compose, fn, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookAheadFunctor

public LookAheadFunctor()
Method Detail

wrap

protected LookAheadIterator<T> wrap(java.util.Iterator<? extends T> iterator,
                                    int count)
Conditionally wraps the input iterator in a LookAheadIterator for return. Uses a Wrapper to determine if the input iterator is one that this object has already built and returned: if so, then there is no need to wrap it again.



Copyright © 2002-2005 David A. Hall. All Rights Reserved.