@Override public <X> Flow<X> mapcat(Mapper<T, Flow<X>> mapper) { return F.emptyFlow(); }
/** Does nothing; returns this empty list (as a Flow<X>). */ @Override public <X> Flow<X> map(Mapper<T, X> mapper) { return F.emptyFlow(); }
@Override public <X> Flow<X> mapcat(Mapper<T, Flow<X>> mapper) { return F.emptyFlow(); }
@Override public Flow<T> take(int length) { if (length < 1) return F.emptyFlow(); return new ArrayFlow<T>(values, start, Math.min(count, length)); }
@Override public Flow<T> drop(int length) { assert length >= 0; if (length == 0) return this; if (length >= count) return F.emptyFlow(); return new ArrayFlow<T>(values, start + length, count - length); } }
/** * Creates a new Flow from the values. You should not change the values array * after invoking this method (i.e., no defensive copy of the values is made). */ public static <T> Flow<T> flow(T... values) { if (values.length == 0) return emptyFlow(); return new ArrayFlow<T>(values); }
private Flow<T> buildRest() { if (count < 2) return F.emptyFlow(); return new ArrayFlow<T>(values, start + 1, count - 1); }
/** * Creates a new Flow from the values. You should not change the values array * after invoking this method (i.e., no defensive copy of the values is made). */ public static <T> Flow<T> flow(T... values) { if (values.length == 0) return emptyFlow(); return new ArrayFlow<T>(values); }
private Flow<T> buildRest() { if (count < 2) return F.emptyFlow(); return new ArrayFlow<T>(values, start + 1, count - 1); }
/** * Extracts the values from the collection to form a {@link Flow}. The Collection * may change after the Flow is created without affecting the Flow. */ public static <T> Flow<T> flow(Collection<T> values) { assert values != null; if (values.isEmpty()) return emptyFlow(); return new ArrayFlow<T>(values); }
@Override public Flow<T> drop(int length) { assert length >= 0; if (length == 0) return this; if (length >= count) return F.emptyFlow(); return new ArrayFlow<T>(values, start + length, count - length); } }
/** * Extracts the values from the collection to form a {@link Flow}. The Collection * may change after the Flow is created without affecting the Flow. */ public static <T> Flow<T> flow(Collection<T> values) { assert values != null; if (values.isEmpty()) return emptyFlow(); return new ArrayFlow<T>(values); }
@Override public Flow<T> reverse() { if (isEmpty()) return F.emptyFlow(); return new ArrayFlow<T>(this).reverse(); }
@Override public Flow<T> sort(Comparator<T> comparator) { if (isEmpty()) return F.emptyFlow(); return new ArrayFlow<T>(this).sort(comparator); }
@Override public Flow<T> sort() { if (isEmpty()) return F.emptyFlow(); return new ArrayFlow<T>(this).sort(); }
@Override public Flow<T> reverse() { if (isEmpty()) return F.emptyFlow(); return new ArrayFlow<T>(this).reverse(); }
@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)); }
@Test public void empty_flow_to_set() { assertSame(F.emptyFlow().toSet(), Collections.EMPTY_SET); }
@Test public void remove_on_empty_flow() { Flow<Integer> flow = F.emptyFlow(); assertSame(flow.remove(evenp), flow); }