// apply a function to an iterator static IterableIterator mapI(final O f, final Iterator i) { ret new IterableIterator { public bool hasNext() { ret i.hasNext(); } public O next() { ret callF(f, i.next()); } }; } ifclass IterableIterator static IterableIterator map(IterableIterator i, O f) { ret mapI((Iterator) i, f); } endif static IterableIterator mapI(Iterator i, O f) { ret mapI(f, i); } static IterableIterator mapI(Iterable i, O f) { ret mapI(f, i.iterator()); }