Iterator<T> (BooleanFunction<? super T> pred) { if (!buffer.isEmpty()) { for (Iterator<T> it = buffer.iterator(); it.hasNext(); ) { final T elem = it.next(); if (pred.fun(elem)) { it.remove(); return asIterator(elem); } } } while(from.hasNext()) { final T elem = from.next(); if (pred.fun(elem)) { return asIterator(elem); } buffer.add(elem); } buffer.clear(); return Collections.emptyIterator(); }