return (box.a = action -> producer.test(action) ? box.a : null).stream();
@SuppressWarnings("unchecked") @Override public boolean tryAdvance(Consumer<? super T> action) { if (buf != null) { if (buf.tryAdvance(action)) return true; buf = null; } cons = action; for (vals = 0; vals == 0; e = e.next(this)) { if (e == null) return false; } if (vals > 1) { buf = ((Stream.Builder<T>) cons).build().spliterator(); } cons = null; return true; }
/** * Returns the stream which covers all the elements emitted by this * emitter. * * @return the new stream */ default StreamEx<T> stream() { return of(spliterator()); } }
@Override public void forEachRemaining(Consumer<? super T> action) { if (buf != null) { buf.forEachRemaining(action); buf = null; } StreamEx.Emitter<T> e = this.e; this.e = null; while (e != null) e = e.next(action); }