@Test public void reduceTest() { assertEquals(45, (int) range(10).reduce(new Transform<Pair<Integer, Integer>, Integer>() { @Override public Integer transform(Pair<Integer, Integer> pair) { return pair.first() + pair.second(); } })); assertEquals(9, (int) range(10).reduce(new Transform<Pair<Integer, Integer>, Integer>() { @Override public Integer transform(Pair<Integer, Integer> pair) { return max(pair.first(), pair.second()); } })); assertEquals(9, (int) range(10).reduce(Transforms.<Integer> max())); assertEquals(0, (int) range(10).reduce(Transforms.<Integer> min())); }
public T reduce(Transform<Pair<T, T>, T> function) { return reduce(function, takeOne()); }
Sequence implements Iterable<T> { public T reduce(Transform<Pair<T, T>, T> function) { return reduce(function, takeOne()); } }
Sequence implements Iterable<T> { public T reduce(Transform<Pair<T, T>, T> function) { return reduce(function, takeOne()); } Sequence(Collection<? extends T> collection);  Sequence(Iterator<? extends T> iterator);  Sequence(Iterator<? extends T> iterator, int size);  Sequence(Iterable<? extends T> iterable);  Sequence(Iterable<? extends T> iterable, int size); protected  Sequence(); }
Sequence implements Iterable<T> { public T reduce(Transform<Pair<T, T>, T> function) { return reduce(function, takeOne()); } Sequence(Collection<? extends T> collection);  Sequence(Iterator<? extends T> iterator);  Sequence(Iterator<? extends T> iterator, int size);  Sequence(Iterable<? extends T> iterable);  Sequence(Iterable<? extends T> iterable, int size); protected  Sequence(); static Sequence<T> fromIterable(Iterable<? extends T> iterable); static Sequence<T> fromIterator(Iterator<? extends T> iterator); static Sequence<T> fromCollection(Collection<? extends T> collection); static Sequence<T> singleton(T object); static Sequence<T> emptySequence(); static int iterableSize(Iterable<?> iterable); static int iterableSize(Iterable<?> iterable, int defaultSize); @Override final Iterator<T> iterator(); T getFirst(); T takeOne(); Sequence<T> take(final int size); Sequence<Sequence<T>> slice(final int sliceSize); Sequence<Sequence<T>> partition(int sliceSize); Sequence<Sequence<T>> split(int blocks); Sequence<Pair<T, T>> consecutivePairs(); Sequence<Pair<T, T>> consecutivePairs(final boolean includeLast); Sequence<T> drop(int size); void finished(); Sequence<U> map(Transform<? super T, ? extends U> func); Sequence<U> transform(Transform<? super T, ? extends U> transform); Sequence<U> collect(Transform<? super T, ? extends U> transform); Multimap<U, V> toMultiMap(Transform<? super T, ? extends Pair<U, V>> transform); Multimap<U, V> toMultiMap(Transform<? super T, ? extends Pair<U, V>> transform,
			Factory<Multimap<U, V>> factory); Map<U, V> toMap(Transform<? super T, ? extends Pair<U, V>> transform); Map<U, V> toMap(Transform<? super T, ? extends Pair<U, V>> transform, Map<U, V> map); Map<T, U> keysToMap(Transform<? super T, ? extends U> transform); Map<T, U> keysToMap(Transform<? super T, ? extends U> transform, Factory<Map<T, U>> factory); Sequence<T> select(Filter<? super T> filter); Sequence<T> filter(Filter<? super T> filter); Sequence<T> reject(Filter<? super T> filter); @SuppressWarnings("unchecked") T find(Filter<? super T> filter); Sequence<T> add(T element); Sequence<T> add(Iterable<? extends T> other); Sequence<T> addLast(T element); Sequence<T> addLast(Iterable<? extends T> other); Sequence<T> addFirst(T element); Sequence<T> addFirst(Iterable<? extends T> other); T reduce(Transform<Pair<T, T>, T> function); T reduce(Transform<Pair<T, T>, T> function, T seed); Sequence<Pair<Integer, T>> enumerate(); Sequence<Pair<T, U>> zip(Iterable<U> other); S aggregate(S start, Aggregate<S, ? super T> aggregator); T aggregate(Aggregate<T, ? super T> aggregator); Sequence<T> info(String description); Sequence<T> info(String description, Class<? extends ProgressInfo> clazz); Sequence<T> defensiveCopy(); Sequence<T> materialise(); Sequence<T> setSize(int size); List<T> toImmutableList(); List<T> toList(); List<T> toList(Factory<List<T>> factory); List<F> toSortedList(); List<F> toSortedList(Comparator<? super F> order); List<T> sort(Comparator<T> comparator); Sequence<T> unpackedSort(Comparator<T> comparator); Set<T> toSet(); Set<T> toSet(Factory<Set<T>> factory); Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(Class<T> valClass); C addToCollection(C collection); C toCollection(C collection); Collection<T> asCollection(); boolean isSizeKnown(); int size(); int size(int defaultSize); boolean isEmpty(); int computeSize(); boolean computeIsEmpty(); boolean any(Filter<? super T> filter); boolean all(Filter<? super T> filter); boolean none(Filter<? super T> filter); String join(String separator); @Override String toString(); }
Sequence implements Iterable<T> { public T reduce(Transform<Pair<T, T>, T> function) { return reduce(function, takeOne()); } Sequence(Collection<? extends T> collection);  Sequence(Iterator<? extends T> iterator);  Sequence(Iterator<? extends T> iterator, int size);  Sequence(Iterable<? extends T> iterable);  Sequence(Iterable<? extends T> iterable, int size); protected  Sequence(); static Sequence<T> fromIterable(Iterable<? extends T> iterable); static Sequence<T> fromIterator(Iterator<? extends T> iterator); static Sequence<T> fromCollection(Collection<? extends T> collection); static Sequence<T> singleton(T object); static Sequence<T> emptySequence(); static int iterableSize(Iterable<?> iterable); static int iterableSize(Iterable<?> iterable, int defaultSize); @Override final Iterator<T> iterator(); T getFirst(); T takeOne(); Sequence<T> take(final int size); Sequence<Sequence<T>> slice(final int sliceSize); Sequence<Sequence<T>> partition(int sliceSize); Sequence<Sequence<T>> split(int blocks); Sequence<Pair<T, T>> consecutivePairs(); Sequence<Pair<T, T>> consecutivePairs(final boolean includeLast); Sequence<T> drop(int size); void finished(); Sequence<U> map(Transform<? super T, ? extends U> func); Sequence<U> transform(Transform<? super T, ? extends U> transform); Sequence<U> collect(Transform<? super T, ? extends U> transform); Multimap<U, V> toMultiMap(Transform<? super T, ? extends Pair<U, V>> transform); Multimap<U, V> toMultiMap(Transform<? super T, ? extends Pair<U, V>> transform,
			Factory<Multimap<U, V>> factory); Map<U, V> toMap(Transform<? super T, ? extends Pair<U, V>> transform); Map<U, V> toMap(Transform<? super T, ? extends Pair<U, V>> transform, Map<U, V> map); Map<T, U> keysToMap(Transform<? super T, ? extends U> transform); Map<T, U> keysToMap(Transform<? super T, ? extends U> transform, Factory<Map<T, U>> factory); Sequence<T> select(Filter<? super T> filter); Sequence<T> filter(Filter<? super T> filter); Sequence<T> reject(Filter<? super T> filter); @SuppressWarnings("unchecked") T find(Filter<? super T> filter); Sequence<T> add(T element); Sequence<T> add(Iterable<? extends T> other); Sequence<T> addLast(T element); Sequence<T> addLast(Iterable<? extends T> other); Sequence<T> addFirst(T element); Sequence<T> addFirst(Iterable<? extends T> other); T reduce(Transform<Pair<T, T>, T> function); T reduce(Transform<Pair<T, T>, T> function, T seed); Sequence<Pair<Integer, T>> enumerate(); Sequence<Pair<T, U>> zip(Iterable<U> other); S aggregate(S start, Aggregate<S, ? super T> aggregator); T aggregate(Aggregate<T, ? super T> aggregator); Sequence<T> info(String description); Sequence<T> info(String description, Class<? extends ProgressInfo> clazz); Sequence<T> defensiveCopy(); Sequence<T> materialise(); Sequence<T> setSize(int size); List<T> toImmutableList(); List<T> toList(); List<T> toList(Factory<List<T>> factory); List<F> toSortedList(); List<F> toSortedList(Comparator<? super F> order); List<T> sort(Comparator<T> comparator); Sequence<T> unpackedSort(Comparator<T> comparator); Set<T> toSet(); Set<T> toSet(Factory<Set<T>> factory); Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(Class<T> valClass); C addToCollection(C collection); C toCollection(C collection); Collection<T> asCollection(); boolean isSizeKnown(); int size(); int size(int defaultSize); boolean isEmpty(); int computeSize(); boolean computeIsEmpty(); boolean any(Filter<? super T> filter); boolean all(Filter<? super T> filter); boolean none(Filter<? super T> filter); String join(String separator); @Override String toString(); static final int UNKNOWN_SIZE; }