@Override public Flow<T> take(int length) { return F.lazy(new LazyTake<T>(length, this)); }
@Override public Flow<T> drop(int length) { assert length >= 0; if (length == 0) return this; return F.lazy(new LazyDrop<T>(length, this)); }
@Override public Flow<T> drop(int length) { assert length >= 0; if (length == 0) return this; return F.lazy(new LazyDrop<T>(length, this)); }
@Override public Flow<T> interleave(Flow<T>... otherFlows) { List<Flow<T>> allFlows = new ArrayList<Flow<T>>(otherFlows.length + 1); allFlows.add(this); for (Flow<T> otherFlow : otherFlows) { allFlows.add(otherFlow); } return F.lazy(new Interleaver<T>(allFlows)); } }
@Override public Flow<T> concat(Flow<? extends T> other) { return F.lazy(new LazyConcat<T>(this, other)); }
/** * Creates a lazy Flow from the {@link Iterator}. The Flow will be threadsafe as long as the underlying iterable * object is not modified while the Flow is evaluating. In other words, not extremely threadsafe. * * @since 5.3 */ public static <T> Flow<T> flow(Iterator<T> iterator) { return lazy(new LazyIterator<T>(iterator)); }
@Override public Flow<T> filter(Predicate<? super T> predicate) { assert predicate != null; return F.lazy(new LazyFilter<T>(predicate, this)); }
@Override public Flow<T> filter(Predicate<? super T> predicate) { assert predicate != null; return F.lazy(new LazyFilter<T>(predicate, this)); }
/** * Creates a lazy Flow from the {@link Iterator}. The Flow will be threadsafe as long as the underlying iterable * object is not modified while the Flow is evaluating. In other words, not extremely threadsafe. * * @since 5.3 */ public static <T> Flow<T> flow(Iterator<T> iterator) { return lazy(new LazyIterator<T>(iterator)); }
@Override public <X> Flow<X> map(Mapper<T, X> mapper) { assert mapper != null; return F.lazy(new LazyMapper<T, X>(mapper, this)); }
@Override public <X> Flow<X> map(Mapper<T, X> mapper) { assert mapper != null; return F.lazy(new LazyMapper<T, X>(mapper, this)); }
@Override public Flow<T> take(int length) { return F.lazy(new LazyTake<T>(length, this)); }
@Override public Flow<T> concat(Flow<? extends T> other) { return F.lazy(new LazyConcat<T>(this, other)); }
@Override public Flow<T> interleave(Flow<T>... otherFlows) { List<Flow<T>> allFlows = new ArrayList<Flow<T>>(otherFlows.length + 1); allFlows.add(this); for (Flow<T> otherFlow : otherFlows) { allFlows.add(otherFlow); } return F.lazy(new Interleaver<T>(allFlows)); } }
@Override public <X> ZippedFlow<T, X> zipWith(Flow<X> otherFlow) { assert otherFlow != null; Flow<Tuple<T, X>> tupleFlow = F.lazy(new LazyZip<T, X>(this, otherFlow)); return ZippedFlowImpl.create(tupleFlow); }
/** * Creates a lazy Flow that returns integers in the given range. The range starts * with the lower value and counts by 1 up to the upper range (which is not part of * the Flow). If lower equals upper, the Flow is empty. If upper is less than lower, * the Flow counts down instead. * * @param lower * start of range (inclusive) * @param upper * end of range (exclusive) */ public static Flow<Integer> range(int lower, int upper) { if (lower == upper) return F.emptyFlow(); if (lower < upper) return lazy(new LazyRange(lower, upper, 1)); return lazy(new LazyRange(lower, upper, -1)); }
@Override public <X> ZippedFlow<T, X> zipWith(Flow<X> otherFlow) { assert otherFlow != null; Flow<Tuple<T, X>> tupleFlow = F.lazy(new LazyZip<T, X>(this, otherFlow)); return ZippedFlowImpl.create(tupleFlow); }
/** * Creates a lazy Flow that returns integers in the given range. The range starts * with the lower value and counts by 1 up to the upper range (which is not part of * the Flow). If lower equals upper, the Flow is empty. If upper is less than lower, * the Flow counts down instead. * * @param lower * start of range (inclusive) * @param upper * end of range (exclusive) */ public static Flow<Integer> range(int lower, int upper) { if (lower == upper) return F.emptyFlow(); if (lower < upper) return lazy(new LazyRange(lower, upper, 1)); return lazy(new LazyRange(lower, upper, -1)); }
@Override public <X, Y> Flow<Y> map(Mapper2<T, X, Y> mapper, Flow<? extends X> flow) { assert mapper != null; assert flow != null; if (this.isEmpty() || flow.isEmpty()) return F.emptyFlow(); return F.lazy(new LazyMapper2<T, X, Y>(mapper, this, flow)); }
@Override public <X, Y> Flow<Y> map(Mapper2<T, X, Y> mapper, Flow<? extends X> flow) { assert mapper != null; assert flow != null; if (this.isEmpty() || flow.isEmpty()) return F.emptyFlow(); return F.lazy(new LazyMapper2<T, X, Y>(mapper, this, flow)); }