public abstract class BaseExtendedStream<T> extends java.lang.Object implements Unwrapable, ReactiveSeq<T>, java.lang.Iterable<T>
empty
Constructor and Description |
---|
BaseExtendedStream() |
Modifier and Type | Method and Description |
---|---|
boolean |
allMatch(java.util.function.Predicate<? super T> c)
True if predicate matches all elements when Monad converted to a Stream
|
boolean |
anyMatch(java.util.function.Predicate<? super T> c)
True if a single element matches when Monad converted to a Stream
|
void |
close() |
<R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Performs a mutable
reduction operation on the elements of this stream using a
Collector . |
<R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this stream.
|
protected abstract <R> ReactiveSeq<R> |
createSeq(java.util.stream.Stream<R> rStream) |
ReactiveSeq<T> |
debounce(long time,
java.util.concurrent.TimeUnit t)
Allow one element through per time period, drop all other elements in
that time period
|
boolean |
endsWith(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
|
abstract ReactiveSeq<T> |
filterLazyPredicate(java.util.function.Supplier<java.util.function.Predicate<? super T>> fn) |
java.util.Optional<T> |
findAny() |
T |
firstValue(T alt)
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
|
ReactiveSeq<T> |
fixedDelay(long l,
java.util.concurrent.TimeUnit unit)
emit elements after a fixed delay
|
<R> ReactiveSeq<R> |
flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
flatMap operation
|
java.util.stream.DoubleStream |
flatMapToDouble(java.util.function.Function<? super T,? extends java.util.stream.DoubleStream> mapper) |
java.util.stream.IntStream |
flatMapToInt(java.util.function.Function<? super T,? extends java.util.stream.IntStream> mapper) |
java.util.stream.LongStream |
flatMapToLong(java.util.function.Function<? super T,? extends java.util.stream.LongStream> mapper) |
T |
foldLeft(Monoid<T> reducer) |
T |
foldLeft(T identity,
java.util.function.BinaryOperator<T> accumulator) |
<R> R |
foldLeftMapToType(Reducer<R,T> reducer) |
<R> R |
foldMap(java.util.function.Function<? super T,? extends R> mapper,
Monoid<R> reducer)
ReactiveSeq.of("one","two","three","four")
.foldMap(this::toInt,Reducers.toTotalInt());
//10
int toInt(String s){
if("one".equals(s))
return 1;
if("two".equals(s))
return 2;
if("three".equals(s))
return 3;
if("four".equals(s))
return 4;
return -1;
}
|
<R> R |
foldMap(Reducer<R,T> reducer)
ReactiveSeq.of("hello","2","world","4").foldMap(Reducers.toCountInt());
//4
|
<R> R |
foldMapRight(Reducer<R,T> reducer)
Attempt to transform this Monad to the same type as the supplied Monoid (using
mapToType on the monoid interface) Then use Monoid to reduce values
|
T |
foldRight(Monoid<T> reducer)
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
|
T |
foldRight(T identity,
java.util.function.BinaryOperator<T> accumulator)
Immutable reduction from right to left
|
<U> U |
foldRight(U seed,
java.util.function.BiFunction<? super T,? super U,? extends U> function)
Immutable reduction from right to left
|
void |
forEachOrdered(java.util.function.Consumer<? super T> action) |
boolean |
isParallel() |
ReactiveSeq<T> |
jitter(long l)
Introduce a random jitter / time delay between the emission of elements
|
java.lang.String |
join()
assertEquals("123".length(),ReactiveSeq.of(1, 2, 3).join().length());
|
java.lang.String |
join(java.lang.String sep)
assertEquals("1, 2, 3".length(), ReactiveSeq.of(1, 2, 3).join(", ").length());
|
java.lang.String |
join(java.lang.String sep,
java.lang.String start,
java.lang.String end)
assertEquals("^1|2|3$".length(), of(1, 2, 3).join("|", "^", "$").length());
|
abstract <R> ReactiveSeq<R> |
mapLazyFn(java.util.function.Supplier<java.util.function.Function<? super T,? extends R>> fn) |
java.util.stream.DoubleStream |
mapToDouble(java.util.function.ToDoubleFunction<? super T> mapper) |
java.util.stream.IntStream |
mapToInt(java.util.function.ToIntFunction<? super T> mapper) |
java.util.stream.LongStream |
mapToLong(java.util.function.ToLongFunction<? super T> mapper) |
java.util.Optional<T> |
max(java.util.Comparator<? super T> comparator) |
java.util.Optional<T> |
min(java.util.Comparator<? super T> comparator) |
boolean |
noneMatch(java.util.function.Predicate<? super T> c) |
ReactiveSeq<T> |
onClose(java.lang.Runnable closeHandler) |
ReactiveSeq<T> |
onePer(long time,
java.util.concurrent.TimeUnit t)
emit one element per time period
|
ReactiveSeq<T> |
parallel() |
java.util.Optional<T> |
reduce(java.util.function.BinaryOperator<T> accumulator) |
Seq<T> |
reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
Reduce with multiple reducers in parallel NB if this Monad is an Optional
[Arrays.asList(1,2,3)] reduce will operate on the Optional as if the list
was one value To reduce over the values on the list, called
streamedMonad() first.
|
T |
reduce(Monoid<T> reducer)
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
|
T |
reduce(T identity,
java.util.function.BinaryOperator<T> accumulator) |
<U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner) |
ReactiveSeq<T> |
sequential() |
ReactiveSeq<T> |
sorted()
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7))); |
boolean |
startsWith(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
|
ReactiveSeq<T> |
stream()
Convert this ReactiveSeq into a Stream
|
java.lang.Object[] |
toArray() |
<A> A[] |
toArray(java.util.function.IntFunction<A[]> generator) |
java.util.List<T> |
toList() |
java.util.Set<T> |
toSet()
Collect the collectable into a
LinkedHashSet . |
ReactiveSeq<T> |
unordered() |
abstract java.util.stream.Stream<T> |
unwrapStream() |
boolean |
xMatch(int num,
java.util.function.Predicate<? super T> c)
Check that there are specified number of matches of predicate in the
Stream
|
ReactiveSeq<T> |
xPer(int x,
long time,
java.util.concurrent.TimeUnit t)
emit x elements per time period
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
unwrap, unwrapIfInstance, unwrapNested
ambWith, ambWith, append, appendAll, appendAll, appendStream, backpressureAware, broadcast, changes, coflatMap, collectAll, combinations, combinations, combine, combine, concat, concat, concat, concat, concatDoubles, concatInts, concatLongs, concatMap, concatMapnts, count, crossJoin, cycle, cycle, cycle, cycleUntil, cycleWhile, defer, deferFromPublisher, deferFromStream, deleteBetween, distinct, distinct, doubles, drop, drop, dropRight, dropUntil, dropUntilInclusive, dropWhile, dropWhileInclusive, duplicate, duplicate, elapsed, elementAt, elementAtAndStream, empty, enqueued, enqueued, enqueued, enqueuedAll, enums, enums, enums, enumsFromTo, fanOut, fanOut, fanOut, fanOutZipIn, fanOutZipIn, fanOutZipIn, fill, filter, filterInts, filterLongs, filterLongs, filterNot, findFirst, findFirstOrError, flatMap, flatMapDoubles, flatMapLongs, flatten, flattenIterable, fold, foldParallel, foldParallel, forEach, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, forEachAsync, fromCharSequence, fromDoubleStream, fromIntStream, fromIterable, fromIterator, fromList, fromLongStream, fromPublisher, fromSpliterator, fromStream, generate, generate, groupBy, grouped, grouped, groupedBySizeAndTime, groupedBySizeAndTime, groupedBySizeAndTime, groupedByTime, groupedByTime, groupedByTime, groupedUntil, groupedUntil, groupedUntil, groupedUntil, groupedWhile, groupedWhile, groupedWhile, groupedWhile, headOption, hotStream, insertAt, insertAt, insertAt, insertAt, insertStreamAt, intersperse, ints, isEmpty, isReplayable, iterate, iterate, limit, limitDouble, limitInts, limitLongs, longs, map, mapDoubles, mapInts, mapLongs, merge, merge, merge, mergeMap, mergeMap, mergeP, mergeP, multicast, narrow, narrowK, notNull, of, of, ofDoubles, ofInts, ofLongs, ofNullable, ofType, onComplete, onEmpty, onEmptyError, onEmptyGet, onEmptySwitch, onError, oneShotList, oneShotStream, parallel, parallel, parallelFanOut, parallelFanOut, parallelFanOut, parallelFanOutZipIn, parallelFanOutZipIn, parallelFanOutZipIn, partition, pausableHotStream, peek, permutations, plus, plusAll, prepend, prependAll, prependAll, prependStream, primedHotStream, primedPausableHotStream, print, print, printErr, printOut, publishTo, publishTo, quadruplicate, quadruplicate, range, range, rangeLong, rangeLong, reactiveSeq, recover, recover, recoverWith, recoverWith, recoverWith, reduce, reduceAll, removeAll, removeAll, removeAt, removeFirst, removeStream, removeValue, retainAll, retainAll, retainStream, retry, retry, reverse, reversedListOf, reversedOf, scanLeft, scanLeft, scanRight, scanRight, schedule, scheduleFixedDelay, scheduleFixedRate, shuffle, shuffle, single, single, singleOrElse, size, skip, skipDoubles, skipInts, skipLongs, slice, sliding, sliding, sorted, sorted, sorted, splitAt, splitAtHead, splitBy, spliterator, subStream, tailRec, take, take, takeOne, takeRight, takeUntil, takeUntilInclusive, takeWhile, takeWhileInclusive, timestamp, triplicate, triplicate, unfold, unit, unzip, unzip3, unzip4, updateAt, widen, zip, zip, zip, zip3, zip3, zip4, zip4, zipLatest, zipWithIndex, zipWithPublisher, zipWithStream, zipWithStream
asFunction, containsValue, equalToIteration, foldFuture, foldLazy, foldTry, forEach, forEach, forEach, forEach, forEach, forEachSubscribe, forEachSubscribe, forEachSubscribe, runFuture, runLazy, seq, to, toHashSet, unitIterable
subscribe, traversable
atPercentile, bankersQueue, collect, collect, countDistinct, doubleStats, foldLeft, foldLeft, foldLeft, foldLeft, hashSet, indexOf, indexOfSlice, intStats, iterableTo, lastIndexOf, lastIndexOfSlice, lazySeq, longStats, maxBy, maxBy, maximum, mean, median, minBy, minBy, minimum, mode, nonEmptyList, occurances, populationVariance, scheduleStream, stdDeviation, sumDouble, sumInt, sumLong, toCollection, toHashMap, toHashMap, toMap, toMap, treeSet, variance, vector, withPercentiles
public abstract java.util.stream.Stream<T> unwrapStream()
public final ReactiveSeq<T> parallel()
parallel
in interface ReactiveSeq<T>
parallel
in interface java.util.stream.BaseStream<T,java.util.stream.Stream<T>>
public boolean endsWith(java.lang.Iterable<T> iterable)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
public boolean allMatch(java.util.function.Predicate<? super T> c)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
public boolean anyMatch(java.util.function.Predicate<? super T> c)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5).anyMatch(it-> it.equals(3)),equalTo(true));
public boolean xMatch(int num, java.util.function.Predicate<? super T> c)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,5,6,7).xMatch(3, i-> i>4 ));
public final boolean noneMatch(java.util.function.Predicate<? super T> c)
public final java.lang.String join()
ReactiveSeq
assertEquals("123".length(),ReactiveSeq.of(1, 2, 3).join().length());
public final java.lang.String join(java.lang.String sep)
ReactiveSeq
assertEquals("1, 2, 3".length(), ReactiveSeq.of(1, 2, 3).join(", ").length());
public final java.lang.String join(java.lang.String sep, java.lang.String start, java.lang.String end)
ReactiveSeq
assertEquals("^1|2|3$".length(), of(1, 2, 3).join("|", "^", "$").length());
public final java.util.Optional<T> min(java.util.Comparator<? super T> comparator)
min
in interface ReactiveSeq<T>
min
in interface java.util.stream.Stream<T>
public final java.util.Optional<T> max(java.util.Comparator<? super T> comparator)
max
in interface ReactiveSeq<T>
max
in interface java.util.stream.Stream<T>
public final java.util.Optional<T> findAny()
findAny
in interface ReactiveSeq<T>
findAny
in interface java.util.stream.Stream<T>
ReactiveSeq.of(1,2,3,4,5).filter(it -> it <3).findAny().getValue();
//3
(non-deterministic)public final <R> R foldMap(Reducer<R,T> reducer)
ReactiveSeq
ReactiveSeq.of("hello","2","world","4").foldMap(Reducers.toCountInt());
//4
public final <R> R foldMap(java.util.function.Function<? super T,? extends R> mapper, Monoid<R> reducer)
ReactiveSeq
ReactiveSeq.of("one","two","three","four")
.foldMap(this::toInt,Reducers.toTotalInt());
//10
int toInt(String s){
if("one".equals(s))
return 1;
if("two".equals(s))
return 2;
if("three".equals(s))
return 3;
if("four".equals(s))
return 4;
return -1;
}
public <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
ReactiveSeq
Collector
. A Collector
encapsulates the function used as arguments to
ReactiveSeq.collect(Supplier, BiConsumer, BiConsumer)
, allowing for reuse of
toX strategies and composition of collect operations such as
multiple-level grouping or partitioning.
If the stream is parallel, and the Collector
is concurrent
, and
lazy the stream is unordered or the collector is
unordered
,
applyHKT a concurrent reduction will be performed (see Collector
for
details on concurrent reduction.)
This is a terminal operation.
When executed in parallel, multiple intermediate results may be
instantiated, populated, and merged so as to maintain isolation of
mutable data structures. Therefore, even when executed in parallel
with non-thread-safe data structures (such as ArrayList
), no
additional synchronization is needed for a parallel reduction.
collect
in interface Folds<T>
collect
in interface ReactiveSeq<T>
collect
in interface java.util.stream.Stream<T>
collector
- the Collector
describing the reductionReactiveSeq.collect(Supplier, BiConsumer, BiConsumer)
,
Collectors
public <R> R collect(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super T> accumulator, java.util.function.BiConsumer<R,R> combiner)
ReactiveSeq
ArrayList
, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
R result = supplier.getValue();
for (T element : this stream)
accumulator.accept(result, element);
return result;
Like ReactiveSeq.reduce(Object, BinaryOperator)
, collect
operations
can be parallelized without requiring additional synchronization.
This is a terminal operation.
collect
in interface Folds<T>
collect
in interface ReactiveSeq<T>
collect
in interface java.util.stream.Stream<T>
supplier
- a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.accumulator
- an associative,
non-interfering,
stateless
function for incorporating an additional element into a resultcombiner
- an associative,
non-interfering,
stateless
function for combining two values, which must be
compatible with the accumulator functionpublic final T reduce(Monoid<T> reducer)
ReactiveSeq
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
reduce
in interface ReactiveSeq<T>
reducer
- Use supplied Monoid to reduce valuespublic <U> U reduce(U identity, java.util.function.BiFunction<U,? super T,U> accumulator, java.util.function.BinaryOperator<U> combiner)
reduce
in interface ReactiveSeq<T>
reduce
in interface java.util.stream.Stream<T>
public final Seq<T> reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
ReactiveSeq
Monoid<Integer> sum = Monoid.of(0,(a,b)->a+b);
Monoid<Integer> mult = Monoid.of(1,(a,b)->a*b);
List<Integer> result = ReactiveSeq.of(1,2,3,4))
.reduce(Arrays.asList(sum,mult) );
assertThat(result,equalTo(Arrays.asList(10,24)));
reduce
in interface ReactiveSeq<T>
public final T foldRight(Monoid<T> reducer)
ReactiveSeq
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
public final <U> U foldRight(U seed, java.util.function.BiFunction<? super T,? super U,? extends U> function)
Folds
public final <R> R foldMapRight(Reducer<R,T> reducer)
ReactiveSeq
ReactiveSeq.of(1,2,3).foldRightMapToType(Reducers.toString(""));
// "321"
foldMapRight
in interface Folds<T>
foldMapRight
in interface ReactiveSeq<T>
reducer
- Monoid to reduce valuespublic final java.util.Set<T> toSet()
Folds
LinkedHashSet
.public final java.util.List<T> toList()
public final ReactiveSeq<T> stream()
ReactiveSeq
public final boolean startsWith(java.lang.Iterable<T> iterable)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
startsWith
in interface Folds<T>
startsWith
in interface ReactiveSeq<T>
public final <R> ReactiveSeq<R> flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3)
.flatMapStream(i->IntStream.of(i))
.toList(),equalTo(Arrays.asList(1,2,3)));
flatMapStream
in interface ReactiveSeq<T>
fn
- to be appliedprotected abstract <R> ReactiveSeq<R> createSeq(java.util.stream.Stream<R> rStream)
public boolean isParallel()
public ReactiveSeq<T> sequential()
sequential
in interface ReactiveSeq<T>
sequential
in interface java.util.stream.BaseStream<T,java.util.stream.Stream<T>>
public ReactiveSeq<T> unordered()
unordered
in interface ReactiveSeq<T>
unordered
in interface java.util.stream.BaseStream<T,java.util.stream.Stream<T>>
public java.util.stream.IntStream mapToInt(java.util.function.ToIntFunction<? super T> mapper)
mapToInt
in interface ReactiveSeq<T>
mapToInt
in interface java.util.stream.Stream<T>
public java.util.stream.LongStream mapToLong(java.util.function.ToLongFunction<? super T> mapper)
mapToLong
in interface ReactiveSeq<T>
mapToLong
in interface java.util.stream.Stream<T>
public java.util.stream.DoubleStream mapToDouble(java.util.function.ToDoubleFunction<? super T> mapper)
mapToDouble
in interface ReactiveSeq<T>
mapToDouble
in interface java.util.stream.Stream<T>
public java.util.stream.IntStream flatMapToInt(java.util.function.Function<? super T,? extends java.util.stream.IntStream> mapper)
flatMapToInt
in interface java.util.stream.Stream<T>
public java.util.stream.LongStream flatMapToLong(java.util.function.Function<? super T,? extends java.util.stream.LongStream> mapper)
flatMapToLong
in interface java.util.stream.Stream<T>
public java.util.stream.DoubleStream flatMapToDouble(java.util.function.Function<? super T,? extends java.util.stream.DoubleStream> mapper)
flatMapToDouble
in interface java.util.stream.Stream<T>
public void forEachOrdered(java.util.function.Consumer<? super T> action)
forEachOrdered
in interface java.util.stream.Stream<T>
public java.lang.Object[] toArray()
public <A> A[] toArray(java.util.function.IntFunction<A[]> generator)
public ReactiveSeq<T> onClose(java.lang.Runnable closeHandler)
onClose
in interface ReactiveSeq<T>
onClose
in interface java.util.stream.BaseStream<T,java.util.stream.Stream<T>>
public void close()
public ReactiveSeq<T> xPer(int x, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
code
SimpleTimer timer = new SimpleTimer();
ReactiveSeq.of(1, 2, 3, 4, 5, 6)
.xPer(6, 100000000, TimeUnit.NANOSECONDS)
.collect(CyclopsCollectors.toList())
.size();
//6
xPer
in interface Traversable<T>
xPer
in interface ReactiveSeq<T>
x
- number of elements to emittime
- periodt
- Time unitpublic final ReactiveSeq<T> sorted()
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7)));
sorted
in interface IterableX<T>
sorted
in interface Traversable<T>
sorted
in interface ReactiveSeq<T>
sorted
in interface java.util.stream.Stream<T>
public abstract <R> ReactiveSeq<R> mapLazyFn(java.util.function.Supplier<java.util.function.Function<? super T,? extends R>> fn)
public abstract ReactiveSeq<T> filterLazyPredicate(java.util.function.Supplier<java.util.function.Predicate<? super T>> fn)
public ReactiveSeq<T> onePer(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.iterate("", last -> "next")
.limit(100)
.batchBySize(10)
.onePer(1, TimeUnit.MICROSECONDS)
.peek(batch -> System.out.println("batched : " + batch))
.flatMap(Collection::stream)
.peek(individual -> System.out.println("Flattened : "
+ individual))
.forEach(a->{});
onePer
in interface Traversable<T>
onePer
in interface ReactiveSeq<T>
time
- periodt
- Time unitpublic ReactiveSeq<T> debounce(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.debounce(1000,TimeUnit.SECONDS).toList();
// 1
debounce
in interface ReactiveSeq<T>
time
- Time to applyHKT debouncing overt
- Time unit for debounce periodpublic ReactiveSeq<T> fixedDelay(long l, java.util.concurrent.TimeUnit unit)
ReactiveSeq
SimpleTimer timer = new SimpleTimer();
ReactiveSeq.of(1, 2, 3, 4, 5, 6)
.fixedDelay(10000, TimeUnit.NANOSECONDS)
.collect(CyclopsCollectors.toList())
.size();
//6
assertThat(timer.getElapsedNanoseconds(), greaterThan(60000l));
fixedDelay
in interface Traversable<T>
fixedDelay
in interface ReactiveSeq<T>
l
- time length in nanos of the delayunit
- for the delaypublic ReactiveSeq<T> jitter(long l)
ReactiveSeq
{ @code SimpleTimer timer = new SimpleTimer(); ReactiveSeq.of(1, 2, 3, 4, 5, 6) .jitter(10000) .collect(CyclopsCollectors.toList()); assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l)); }
jitter
in interface ReactiveSeq<T>
l
- - random number less than this is used for each jitterpublic T foldRight(T identity, java.util.function.BinaryOperator<T> accumulator)
ReactiveSeq
assertTrue(ReactiveSeq.of("a","b","c").foldRight("", String::concat).equals("cba"));
public T firstValue(T alt)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
firstValue
in interface Folds<T>
firstValue
in interface ReactiveSeq<T>
public java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
reduce
in interface ReactiveSeq<T>
reduce
in interface java.util.stream.Stream<T>