1 33 package net.sf.jga.fn.algorithm; 34 35 import java.util.Iterator ; 36 import net.sf.jga.fn.UnaryFunctor; 37 import net.sf.jga.util.LookAheadIterator; 38 39 50 51 abstract class LookAheadFunctor<T> 52 extends UnaryFunctor<Iterator <? extends T>,LookAheadIterator<T>> 53 { 54 60 protected LookAheadIterator<T> wrap(Iterator <? extends T> iterator, int count) { 61 if (iterator instanceof Wrapper && ((Wrapper)iterator).owner == this) 62 return (LookAheadIterator<T>) iterator; 67 68 return new Wrapper<T>(this, iterator, count); 69 } 70 71 76 static private class Wrapper<T> extends LookAheadIterator<T> { 77 private LookAheadFunctor<T> owner; 78 public Wrapper(LookAheadFunctor<T> owner, Iterator <? extends T> iter, int count) { 79 super(iter, count); this.owner = owner; 80 } 81 } 82 } 83 | Popular Tags |