T
- Data type of elements within the Streampublic interface ReactiveSeq<T> extends To<ReactiveSeq<T>>, java.util.stream.Stream<T>, OnEmptySwitch<T,java.util.stream.Stream<T>>, FoldableTraversable<T>, Unit<T>, Higher<ReactiveSeq.µ,T>
Modifier and Type | Interface and Description |
---|---|
static class |
ReactiveSeq.µ |
static class |
ReactiveSeq.Instances |
Modifier and Type | Method and Description |
---|---|
boolean |
allMatch(java.util.function.Predicate<? super T> c)
True if predicate matches all elements when Monad converted toNested a Stream
|
default ReactiveSeq<T> |
ambWith(org.reactivestreams.Publisher<T>... racers) |
default ReactiveSeq<T> |
ambWith(org.reactivestreams.Publisher<T> racer) |
AnyMSeq<Witness.reactiveSeq,T> |
anyM() |
boolean |
anyMatch(java.util.function.Predicate<? super T> c)
True if a single element matches when Monad converted toNested a Stream
|
ReactiveSeq<T> |
append(java.lang.Iterable<? extends T> other) |
ReactiveSeq<T> |
append(T... values)
Append values toNested the take of this ReactiveSeq
|
ReactiveSeq<T> |
append(T value) |
ReactiveSeq<T> |
appendS(java.util.stream.Stream<? extends T> other)
Append Stream toNested this ReactiveSeq
|
default ReactiveSeq<T> |
backpressureAware() |
default Topic<T> |
broadcast() |
default <U> ReactiveSeq<U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream toNested a given type, possibly throwing a
ClassCastException . |
ReactiveSeq<T> |
changes() |
<R> ReactiveSeq<R> |
coflatMap(java.util.function.Function<? super ReactiveSeq<T>,? extends R> fn)
coflatMap pattern, can be used toNested perform maybe reductions / collections / folds and other terminal operations
|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Performs a mutable
reduction operation on the elements of this reactiveStream using a
Collector . |
default <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 reactiveStream.
|
default <R,A> ReactiveSeq<R> |
collectStream(java.util.stream.Collector<? super T,A,R> collector) |
default ReactiveSeq<ReactiveSeq<T>> |
combinations()
ReactiveSeq.of(1,2,3).combinations()
//ReactiveSeq[ReactiveSeq[],ReactiveSeq[1],ReactiveSeq[2],ReactiveSeq[3].ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]
,ReactiveSeq[1,2,3]]
|
default ReactiveSeq<ReactiveSeq<T>> |
combinations(int size)
ReactiveSeq.of(1,2,3).combinations(2)
//ReactiveSeq[ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]]
|
default StreamT<Witness.reactiveSeq,T> |
combinationsT() |
default StreamT<Witness.reactiveSeq,T> |
combinationsT(int size) |
default ReactiveSeq<T> |
combine(java.util.function.BiPredicate<? super T,? super T> predicate,
java.util.function.BinaryOperator<T> op)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping and reduction operation.
|
default ReactiveSeq<T> |
combine(Monoid<T> op,
java.util.function.BiPredicate<? super T,? super T> predicate)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping and reduction operation.
|
static <T> ReactiveSeq<T> |
concat(java.util.Spliterator<? extends T>... array) |
static <T> ReactiveSeq<T> |
concat(java.util.Spliterator<? extends T> left,
java.util.Spliterator<? extends T> right) |
static <T> ReactiveSeq<T> |
concat(java.util.stream.Stream<? extends T>... streams) |
static <T> ReactiveSeq<T> |
concat(java.util.stream.Stream<? extends T> left,
java.util.stream.Stream<? extends T> right) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
concatDoubles(ReactiveSeq<java.lang.Double> b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
concatInts(ReactiveSeq<java.lang.Integer> b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
concatLongs(ReactiveSeq<java.lang.Long> b) |
long |
count()
Returns the count of elements in this reactiveStream.
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
crossJoin(ReactiveSeq<? extends U> other)
crossJoin two Streams forming a cartesian product over both
|
ReactiveSeq<T> |
cycle()
Convert toNested a Stream with the values infinitely cycled
|
ReactiveSeq<T> |
cycle(long times)
Convert toNested a Stream with the values repeated specified times
|
default ReactiveSeq<T> |
cycle(Monoid<T> m,
long times)
Convert toNested a Stream with the result of a reduction operation repeated
specified times
|
default ReactiveSeq<T> |
cycleUntil(java.util.function.Predicate<? super T> predicate)
Repeat in a Stream until specified predicate holds
|
default ReactiveSeq<T> |
cycleWhile(java.util.function.Predicate<? super T> predicate)
Repeat in a Stream while specified predicate holds
|
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
|
static <T> ReactiveSeq<T> |
deferred(java.util.function.Supplier<? extends java.util.stream.Stream<? extends T>> lazy) |
static <T> ReactiveSeq<T> |
deferredI(java.util.function.Supplier<? extends java.lang.Iterable<? extends T>> lazy) |
static <T> ReactiveSeq<T> |
deferredP(java.util.function.Supplier<? extends org.reactivestreams.Publisher<? extends T>> lazy) |
default ReactiveSeq<T> |
deleteBetween(int start,
int end)
Delete elements between given indexes in a Stream
|
ReactiveSeq<T> |
distinct() |
<U> ReactiveSeq<T> |
distinct(java.util.function.Function<? super T,? extends U> keyExtractor) |
default ReactiveSeq<java.lang.Double> |
doubles(java.util.function.ToDoubleFunction<? super T> fn,
java.util.function.Function<? super java.util.stream.DoubleStream,? extends java.util.stream.DoubleStream> mapper)
Peform intermediate operations on a primitive IntStream (gives improved performance when working with Integers)
If this ReactiveSeq has an OfInt Spliterator it will be converted directly toNested an IntStream,
otherwise the provided conversion function will be used.
|
default ReactiveSeq<T> |
drop(long drop)
assertThat(ReactiveSeq.of(4,3,6,7).drop(2).toList(),equalTo(Arrays.asList(6,7))); |
default ReactiveSeq<T> |
dropRight(int num)
Generate a new Traversable that drops the specified number elements from the take of this Traversable
|
default ReactiveSeq<T> |
dropUntil(java.util.function.Predicate<? super T> p)
Generate a new Traversable that drops elements from this Traversable until the predicate holds
|
default ReactiveSeq<T> |
dropWhile(java.util.function.Predicate<? super T> p)
Generate a new Traversable that drops elements from this Traversable as long as the predicate holds
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
duplicate()
Duplicate a Stream, buffers intermediate values, leaders may change
positions so a limit can be safely applied toNested the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
duplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
elapsed()
ReactiveSeq.of(1,2,3,4,5)
.elapsed()
.forEach(System.out::println);
|
default org.jooq.lambda.tuple.Tuple2<T,ReactiveSeq<T>> |
elementAt(long index)
Gets the element at index, and returns a Tuple containing the element (it
must be present) and a maybe copy of the Sequence for further processing.
|
static <T> ReactiveSeq<T> |
empty() |
boolean |
endsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Stream.of(5,6)));
|
boolean |
endsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
|
static <T> ReactiveSeq<T> |
enqueued(java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>> sub)
Create a Stream that accepts data via the Subsriber passed into the supplied Consumer.
|
static <T> ReactiveSeq<T> |
enqueued(Queue<T> q,
java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>> sub) |
static <T> ReactiveSeq<T> |
enqueued(QueueFactory<T> factory,
java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>>... subs) |
static <T> ReactiveSeq<T> |
enqueuedAll(java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>>... subs) |
default <R> ReactiveSeq<R> |
fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2) |
default <R> ReactiveSeq<R> |
fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path3) |
default <R> ReactiveSeq<R> |
fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path3,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path4) |
default <R1,R2,R3> ReactiveSeq<R3> |
fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2,
java.util.function.BiFunction<? super R1,? super R2,? extends R3> zipFn) |
default <R1,R2,R3,R4> |
fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R3>> path3,
Fn3<? super R1,? super R2,? super R3,? extends R4> zipFn) |
default <R1,R2,R3,R4,R5> |
fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R3>> path3,
java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R4>> path4,
Fn4<? super R1,? super R2,? super R3,? super R4,? extends R5> zipFn) |
static <T> ReactiveSeq<T> |
fill(T t)
Construct a Stream consisting of a single value repeatedly infinitely (use take / drop etc toNested
switch toNested a finite Stream)
|
ReactiveSeq<T> |
filter(java.util.function.Predicate<? super T> fn)
Keep only elements for which the supplied predicates hold
e.g.
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
filterInts(java.util.function.IntPredicate b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
filterLongs(java.util.function.DoublePredicate b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
filterLongs(java.util.function.LongPredicate b) |
default ReactiveSeq<T> |
filterNot(java.util.function.Predicate<? super T> predicate)
Remove any elements for which the predicate holds (inverse operation toNested filter)
e.g.
|
java.util.Optional<T> |
findAny() |
java.util.Optional<T> |
findFirst() |
Either<java.lang.Throwable,T> |
findFirstOrError()
Lazy / reactive look up of first value , capturing the first error, if one occurs.
|
Maybe<T> |
findOne()
Lazy / reactive analogue of findFirst / findAny from JDK
For push based reactive-streams (created via Spouts.XXX) data will be pushed toNested the returned Maybe on arrival.
|
T |
firstValue()
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> |
flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
flatMap operation
|
<R> ReactiveSeq<R> |
flatMapAnyM(java.util.function.Function<? super T,AnyM<Witness.stream,? extends R>> fn)
Allows flatMap return type toNested be any Monad type
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
flatMapDoubles(java.util.function.DoubleFunction<? extends java.util.stream.DoubleStream> b) |
<R> ReactiveSeq<R> |
flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
FlatMap where the result is a Collection, flattens the resultant
collections into the host ReactiveSeq
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
flatMapInts(java.util.function.IntFunction<? extends java.util.stream.IntStream> b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
flatMapLongs(java.util.function.LongFunction<? extends java.util.stream.LongStream> b) |
<R> ReactiveSeq<R> |
flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn) |
<R> ReactiveSeq<R> |
flatMapP(int maxConcurrency,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn) |
<R> ReactiveSeq<R> |
flatMapP(int maxConcurrency,
QueueFactory<R> factory,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper) |
<R> ReactiveSeq<R> |
flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
flatMap operation
|
static <T1> ReactiveSeq<T1> |
flatten(ReactiveSeq<? extends ReactiveSeq<T1>> nested)
join / flatten one level of a nested hierarchy
|
static <T1> ReactiveSeq<T1> |
flattenI(ReactiveSeq<? extends java.lang.Iterable<T1>> nested) |
static <T1> ReactiveSeq<T1> |
flattenO(ReactiveSeq<? extends java.util.Optional<T1>> nested) |
default <R> R |
foldJooλ(java.util.function.Function<? super org.jooq.lambda.Seq<T>,? extends R> mapper) |
default <R> R |
foldParallel(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends R> fn) |
default <R> R |
foldParallel(java.util.function.Function<? super java.util.stream.Stream<T>,? extends R> fn) |
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 toNested left
|
<U> U |
foldRight(U identity,
java.util.function.BiFunction<? super T,? super U,? extends U> accumulator)
Immutable reduction from right toNested left
|
<T> T |
foldRightMapToType(Reducer<T> reducer)
Attempt toNested map this Monad toNested the same type as the supplied Monoid (using
mapToType on the monoid interface) Then use Monoid toNested reduce values
|
void |
forEach(java.util.function.Consumer<? super T> action)
Performs an action for each element of this Stream.
|
default <R1,R> ReactiveSeq<R> |
forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this Stream and the
supplied reactiveStream
|
default <R1,R> ReactiveSeq<R> |
forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this Stream and the
supplied reactiveStream
|
default <R1,R2,R> ReactiveSeq<R> |
forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this Stream and the
supplied streams
|
default <R1,R2,R> ReactiveSeq<R> |
forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2,
Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this Stream and the
supplied streams
|
default <R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2,
Fn3<? super T,? super R1,? super R2,? extends java.util.stream.BaseStream<R3,?>> stream3,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this Stream and the
supplied streams
|
default <R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2,
Fn3<? super T,? super R1,? super R2,? extends java.util.stream.BaseStream<R3,?>> stream3,
Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this Stream and the
supplied streams
|
default void |
forEachAsync(java.util.function.Consumer<? super T> action)
A potentially non-blocking analog of
forEach(java.util.function.Consumer<? super T>) . |
java.lang.String |
format() |
static com.aol.cyclops2.internal.stream.OneShotStreamX<java.lang.Integer> |
fromCharSequence(java.lang.CharSequence input)
Construct a ReactiveSeq from a String
|
static ReactiveSeq<java.lang.Double> |
fromDoubleStream(java.util.stream.DoubleStream stream)
Construct a ReactiveSeq from a Stream
|
static ReactiveSeq<java.lang.Integer> |
fromIntStream(java.util.stream.IntStream stream)
Construct a ReactiveSeq from a Stream
|
static <T> ReactiveSeq<T> |
fromIterable(java.lang.Iterable<T> iterable)
Construct a ReactiveSeq from an Iterable
|
static <T> ReactiveSeq<T> |
fromIterator(java.util.Iterator<T> iterator)
Construct a ReactiveSeq from an Iterator
|
static <T> ReactiveSeq<T> |
fromList(java.util.List<T> list)
Construct a ReactiveSeq from a List (prefer this method if the source is a
list, as it allows more efficient Stream reversal).
|
static ReactiveSeq<java.lang.Long> |
fromLongStream(java.util.stream.LongStream stream)
Construct a ReactiveSeq from a Stream
|
static <T> ReactiveSeq<T> |
fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
Construct a ReactiveSeq from an Publisher
|
static <T> ReactiveSeq<T> |
fromSpliterator(java.util.Spliterator<T> spliterator)
Construct a ReactiveSeq from the Supplied Spliterator
|
static <T> ReactiveSeq<T> |
fromStream(java.util.stream.Stream<T> stream)
Construct a ReactiveSeq from a Stream
|
static <T> ReactiveSeq<T> |
generate(java.util.function.Supplier<T> s) |
default java.util.Optional<T> |
get(long index)
Return the elementAt index or Optional.empty
|
default <K> MapX<K,ListX<T>> |
groupBy(java.util.function.Function<? super T,? extends K> classifier)
Use classifier function toNested group elements in this Sequence into a Map
|
default <K> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,ReactiveSeq<T>>> |
grouped(java.util.function.Function<? super T,? extends K> classifier)
Group this Traversable by the provided classifying function and collected by the provided Collector
|
default <K,A,D> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,D>> |
grouped(java.util.function.Function<? super T,? extends K> classifier,
java.util.stream.Collector<? super T,A,D> downstream)
Group this Traversable by the provided classifying function and collected by the provided Collector
|
ReactiveSeq<ListX<T>> |
grouped(int groupSize)
Group elements in a Stream
|
<C extends java.util.Collection<? super T>> |
grouped(int size,
java.util.function.Supplier<C> supplier)
Batch elements in a Stream by size into a collection created by the
supplied factory
|
ReactiveSeq<ListX<T>> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit t)
Batch elements by size into a List
|
<C extends java.util.Collection<? super T>> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory)
Batch elements by size into a collection created by the supplied factory
|
<C extends java.util.Collection<? super T>,R> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedByTime(long time,
java.util.concurrent.TimeUnit t)
Batch elements in a Stream by time period
|
<C extends java.util.Collection<? super T>> |
groupedByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory)
Batch elements by time into a collection created by the supplied factory
|
<C extends java.util.Collection<? super T>,R> |
groupedByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
<C extends java.util.Collection<T>,R> |
groupedStatefullyUntil(java.util.function.BiPredicate<C,? super T> predicate,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedStatefullyUntil(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
Create ReactiveSeq of ListX where
each ListX is populated while the supplied bipredicate holds.
|
<C extends java.util.Collection<T>,R> |
groupedStatefullyWhile(java.util.function.BiPredicate<C,? super T> predicate,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate) |
default ReactiveSeq<ListX<T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate)
Create a ReactiveSeq batched by List, where each batch is populated until
the predicate holds
|
default <C extends java.util.Collection<? super T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a ReactiveSeq batched by a Collection, where each batch is populated
until the predicate holds
|
ReactiveSeq<ListX<T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate)
Create a ReactiveSeq batched by List, where each batch is populated while
the predicate holds
|
<C extends java.util.Collection<? super T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a ReactiveSeq batched by a Collection, where each batch is populated
while the predicate holds
|
HeadAndTail<T> |
headAndTail()
extract head and tail together, where head is expected toNested be present
Example :
|
default HotStream<T> |
hotStream(java.util.concurrent.Executor e)
Turns this ReactiveSeq into a HotStream, a connectable Stream, being executed on a thread on the
supplied executor, that is producing data.
|
default ReactiveSeq<T> |
insertAt(int pos,
T... values)
Insert data into a reactiveStream at given position
|
default ReactiveSeq<T> |
insertAtS(int pos,
java.util.stream.Stream<T> stream)
Insert a Stream into the middle of this reactiveStream at the specified position
|
default ReactiveSeq<T> |
intersperse(T value)
Returns a reactiveStream with a given value interspersed between any two values
of this reactiveStream.
|
default ReactiveSeq<java.lang.Integer> |
ints(java.util.function.ToIntFunction<? super T> fn,
java.util.function.Function<? super java.util.stream.IntStream,? extends java.util.stream.IntStream> mapper)
Peform intermediate operations on a primitive IntStream (gives improved performance when working with Integers)
If this ReactiveSeq has an OfInt Spliterator it will be converted directly toNested an IntStream,
otherwise the provided conversion function will be used.
|
default boolean |
isEmpty() |
default boolean |
isReplayable() |
static <T> ReactiveSeq<T> |
iterate(T seed,
java.util.function.Predicate<? super T> pred,
java.util.function.UnaryOperator<T> f) |
static <T> ReactiveSeq<T> |
iterate(T seed,
java.util.function.UnaryOperator<T> f) |
ReactiveSeq<T> |
jitter(long maxJitterPeriodInNanos)
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());
|
default <R> ReactiveSeq<R> |
jooλ(java.util.function.Function<? super org.jooq.lambda.Seq<T>,? extends org.jooq.lambda.Seq<R>> mapper) |
default <W extends WitnessType<W>> |
liftM(W witness) |
ReactiveSeq<T> |
limit(long num)
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3)); |
ReactiveSeq<T> |
limit(long time,
java.util.concurrent.TimeUnit unit)
Return all elements until specified time period has elapsed
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
limitDouble(long maxSize) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
limitInts(long maxSize) |
ReactiveSeq<T> |
limitLast(int num)
Limit results toNested the last x elements in a ReactiveSeq
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
limitLongs(long maxSize) |
ReactiveSeq<T> |
limitUntil(java.util.function.Predicate<? super T> p)
Take elements from the Stream until the predicate returns true, after
which all elements are excluded.
|
default ReactiveSeq<T> |
limitUntilClosed(java.util.function.Predicate<? super T> p) |
ReactiveSeq<T> |
limitWhile(java.util.function.Predicate<? super T> p)
Take elements from the Stream while the predicate holds, once the
predicate returns false all subsequent elements are excluded
|
ReactiveSeq<T> |
limitWhileClosed(java.util.function.Predicate<? super T> predicate) |
default ReactiveSeq<java.lang.Long> |
longs(java.util.function.ToLongFunction<? super T> fn,
java.util.function.Function<? super java.util.stream.LongStream,? extends java.util.stream.LongStream> mapper)
Peform intermediate operations on a primitive IntStream (gives improved performance when working with Integers)
If this ReactiveSeq has an OfInt Spliterator it will be converted directly toNested an IntStream,
otherwise the provided conversion function will be used.
|
<R> ReactiveSeq<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
mapDoubles(java.util.function.DoubleUnaryOperator b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
mapInts(java.util.function.IntUnaryOperator b) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
mapLongs(java.util.function.LongUnaryOperator b) |
<R> R |
mapReduce(java.util.function.Function<? super T,? extends R> mapper,
Monoid<R> reducer)
Attempt toNested map this Monad toNested the same type as the supplied Monoid, using
supplied function Then use Monoid toNested reduce values
|
<R> R |
mapReduce(Reducer<R> reducer)
Attempt toNested map this Sequence toNested the same type as the supplied Monoid
(Reducer) Then use Monoid toNested reduce values
|
default java.util.stream.DoubleStream |
mapToDouble(java.util.function.ToDoubleFunction<? super T> fn) |
default java.util.stream.IntStream |
mapToInt(java.util.function.ToIntFunction<? super T> fn) |
default java.util.stream.LongStream |
mapToLong(java.util.function.ToLongFunction<? super T> fn) |
default java.util.Optional<T> |
max(java.util.Comparator<? super T> comparator)
Get the maximum value by a function.
|
default ReactiveSeq<T> |
merge(Adapter<T>... adapters) |
default ReactiveSeq<T> |
mergeP(org.reactivestreams.Publisher<T>... publishers)
A potentially asynchronous merge operation where data from each publisher may arrive out of order (if publishers
are configured toNested publish asynchronously, users can use the overloaded @see
IterableFunctor#mergePublisher(Collection, QueueFactory)
method toNested forEachAsync asynchronously also. |
default ReactiveSeq<T> |
mergeP(QueueFactory<T> factory,
org.reactivestreams.Publisher<T>... publishers)
A potentially asynchronous merge operation where data from each publisher may arrive out of order (if publishers
are configured toNested publish asynchronously.
|
default java.util.Optional<T> |
min(java.util.Comparator<? super T> comparator)
Get the minimum value by a function.
|
default ListX<ReactiveSeq<T>> |
multicast(int num)
Broadcast the contents of this Stream toNested multiple downstream Streams (determined by supplier parameter).
|
static <T> ReactiveSeq<T> |
narrowK(Higher<ReactiveSeq.µ,T> future)
Convert the raw Higher Kinded Type for ReactiveSeq types into the ReactiveSeq type definition class
|
boolean |
noneMatch(java.util.function.Predicate<? super T> c) |
default ReactiveSeq<T> |
notNull()
Filter elements retaining only values which are not null
|
static <T> ReactiveSeq<T> |
of(T... elements)
Create an efficiently reversable Sequence from the provided elements
|
static <T> ReactiveSeq<T> |
of(T value)
Efficiently construct a ReactiveSeq from a single value
|
static ReactiveSeq<java.lang.Double> |
ofDoubles(double... values) |
static ReactiveSeq<java.lang.Integer> |
ofInts(int... values) |
static ReactiveSeq<java.lang.Long> |
ofLongs(long... values) |
static <T> ReactiveSeq<T> |
ofNullable(T nullable) |
default <U> ReactiveSeq<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a reactiveStream that are of a given type.
|
ReactiveSeq<T> |
onClose(java.lang.Runnable closeHandler) |
default ReactiveSeq<T> |
onEmpty(T value)
If this Container instance is empty, create a new instance containing the provided value
|
ReactiveSeq<T> |
onEmptyGet(java.util.function.Supplier<? extends T> supplier)
If this Container instance is empty, create a new instance containing the value returned from the provided Supplier
|
ReactiveSeq<T> |
onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
If this ReactiveSeq is empty replace it with a another Stream
|
<X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
If this container instance is empty, throw the exception returned by the provided Supplier
|
ReactiveSeq<T> |
onePer(long time,
java.util.concurrent.TimeUnit t)
emit one element per time period
|
static <T> ReactiveSeq<T> |
oneShotList(java.util.List<T> list) |
static <T> ReactiveSeq<T> |
oneShotStream(java.util.stream.Stream<T> stream) |
ReactiveSeq<T> |
parallel() |
default <R> ReactiveSeq<R> |
parallel(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> fn) |
default <R> ReactiveSeq<R> |
parallel(java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> fn) |
default <R> ReactiveSeq<R> |
parallelFanOut(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2) |
default <R> ReactiveSeq<R> |
parallelFanOut(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path3) |
default <R> ReactiveSeq<R> |
parallelFanOut(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path3,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path4) |
default <R1,R2,R3> ReactiveSeq<R3> |
parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2,
java.util.function.BiFunction<? super R1,? super R2,? extends R3> zipFn) |
default <R1,R2,R3,R4> |
parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R3>> path3,
Fn3<? super R1,? super R2,? super R3,? extends R4> zipFn) |
default <R1,R2,R3,R4,R5> |
parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R3>> path3,
java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R4>> path4,
Fn4<? super R1,? super R2,? super R3,? super R4,? extends R5> zipFn) |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
partition(java.util.function.Predicate<? super T> splitter)
Partition a Stream into two one a per element basis, based on predicate's
boolean value
|
default PausableHotStream<T> |
pausableHotStream(java.util.concurrent.Executor e)
Turns this ReactiveSeq into a HotStream, a connectable & pausable Stream, being executed on a thread on the
supplied executor, that is producing data.
|
default ReactiveSeq<T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
default ReactiveSeq<ReactiveSeq<T>> |
permutations()
Generate the permutations based on values in the ReactiveSeq Makes use of
Streamable toNested store intermediate stages in a collection
|
default StreamT<Witness.reactiveSeq,T> |
permutationsT() |
ReactiveSeq<T> |
prepend(java.lang.Iterable<? extends T> other) |
ReactiveSeq<T> |
prepend(T... values)
Prepend given values toNested the skip of the Stream
|
ReactiveSeq<T> |
prepend(T value) |
ReactiveSeq<T> |
prependS(java.util.stream.Stream<? extends T> stream)
Prepend Stream toNested this ReactiveSeq
|
default HotStream<T> |
primedHotStream(java.util.concurrent.Executor e)
Return a HotStream that will skip emitting data when the first connecting Stream connects.
|
default PausableHotStream<T> |
primedPausableHotStream(java.util.concurrent.Executor e)
Return a pausable HotStream that will skip emitting data when the first connecting Stream connects.
|
default void |
print(java.io.PrintStream stream)
Write each element within this Folds in turn toNested the supplied PrintStream
|
default void |
print(java.io.PrintWriter writer)
Write each element within this Folds in turn toNested the supplied PrintWriter
|
default void |
printErr()
Print each value in this Folds toNested the error console in turn (left-toNested-right)
|
default void |
printOut()
Print each value in this Folds toNested the console in turn (left-toNested-right)
|
default ReactiveSeq<T> |
publishTo(Adapter<T>... adapters) |
default ReactiveSeq<T> |
publishTo(Signal<T>... signals) |
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
quadruplicate()
Makes four copies of a Stream Buffers intermediate values, leaders may
change positions so a limit can be safely applied toNested the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
quadruplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
static ReactiveSeq<java.lang.Integer> |
range(int start,
int end)
Create an efficiently reversable Sequence that produces the integers
between skip and take
|
static ReactiveSeq<java.lang.Long> |
rangeLong(long start,
long end)
Create an efficiently reversable Sequence that produces the integers
between skip and take
|
static <T> ReactiveSeq<T> |
reactiveSeq(java.lang.Iterable<T> iterable) |
<EX extends java.lang.Throwable> |
recover(java.lang.Class<EX> exceptionClass,
java.util.function.Function<? super EX,? extends T> fn)
Recover from a particular exception type
|
ReactiveSeq<T> |
recover(java.util.function.Function<? super java.lang.Throwable,? extends T> fn)
Recover from an exception with an alternative value
|
java.util.Optional<T> |
reduce(java.util.function.BinaryOperator<T> accumulator)
An equivalent function toNested
Stream.reduce(BinaryOperator) |
ListX<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
|
ListX<T> |
reduce(java.util.stream.Stream<? 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(T identity,
java.util.function.BinaryOperator<T> accumulator)
An equivalent function toNested
Stream.reduce(Object, BinaryOperator) |
default <U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator)
An equivalent function toNested
Stream.reduce(Object, BinaryOperator) |
<U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner)
An equivalent function toNested
Stream.reduce(Object, BiFunction, BinaryOperator) |
default ReactiveSeq<T> |
reduceAll(T identity,
java.util.function.BinaryOperator<T> accumulator) |
default ReactiveSeq<T> |
remove(T t)
Remove all occurances of the specified element from the ReactiveSeq
|
default ReactiveSeq<T> |
removeAll(T... values)
Remove all supplied elements from this filterable
|
default ReactiveSeq<T> |
removeAllI(java.lang.Iterable<? extends T> it)
Remove all elements in the supplied Iterable from this filterable
|
default ReactiveSeq<T> |
removeAllS(java.util.stream.Stream<? extends T> stream)
Remove all elements in the supplied Stream from this filterable
|
default ReactiveSeq<T> |
retainAll(T... values)
Retain only the supplied elements in the returned Filters
|
default ReactiveSeq<T> |
retainAllI(java.lang.Iterable<? extends T> it)
Retain only the supplied elements in the returned Filters
|
default ReactiveSeq<T> |
retainAllS(java.util.stream.Stream<? extends T> stream)
Retain only the supplied elements in the returned Filters
|
default <R> ReactiveSeq<R> |
retry(java.util.function.Function<? super T,? extends R> fn)
Retry a transformation if it fails.
|
default <R> ReactiveSeq<R> |
retry(java.util.function.Function<? super T,? extends R> fn,
int retries,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Retry a transformation if it fails.
|
ReactiveSeq<T> |
reverse()
Potentially efficient Stream reversal.
|
static <T> ReactiveSeq<T> |
reversedListOf(java.util.List<T> elements)
Construct a Reveresed Sequence from the provided elements Can be reversed
(again) efficiently
|
static <T> ReactiveSeq<T> |
reversedOf(T... elements)
Construct a Reveresed Sequence from the provided elements Can be reversed
(again) efficiently
|
default ReactiveSeq<T> |
scanLeft(Monoid<T> monoid)
Scan left using supplied Monoid
|
<U> ReactiveSeq<U> |
scanLeft(U seed,
java.util.function.BiFunction<? super U,? super T,? extends U> function)
Scan left
|
default ReactiveSeq<T> |
scanRight(Monoid<T> monoid)
Scan right
|
default <U> ReactiveSeq<U> |
scanRight(U identity,
java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
Scan right
|
default HotStream<T> |
schedule(java.lang.String cron,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
default HotStream<T> |
scheduleFixedDelay(long delay,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
default HotStream<T> |
scheduleFixedRate(long rate,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
default org.jooq.lambda.Seq<T> |
seq() |
ReactiveSeq<T> |
sequential() |
default ReactiveSeq<T> |
shuffle() |
default ReactiveSeq<T> |
shuffle(java.util.Random random) |
default T |
single()
//1
ReactiveSeq.of(1).single();
//UnsupportedOperationException
ReactiveSeq.of().single();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).single();
|
default T |
single(java.util.function.Predicate<? super T> predicate) |
default java.util.Optional<T> |
singleOptional()
//Optional[1]
ReactiveSeq.of(1).singleOptional();
//Optional.empty
ReactiveSeq.of().singleOpional();
//Optional.empty
ReactiveSeq.of(1,2,3).singleOptional();
|
default int |
size()
[equivalent toNested count]
|
ReactiveSeq<T> |
skip(long num)
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7))); |
ReactiveSeq<T> |
skip(long time,
java.util.concurrent.TimeUnit unit)
Skip all elements until specified time period has passed
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> |
skipDoubles(long skip) |
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> |
skipInts(long skip) |
ReactiveSeq<T> |
skipLast(int num)
assertThat(ReactiveSeq.of(1,2,3,4,5) .skipLast(2)
.collect(CyclopsCollectors.toList()),equalTo(Arrays.asList(1,2,3)));
|
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> |
skipLongs(long skip) |
default ReactiveSeq<T> |
skipUntil(java.util.function.Predicate<? super T> p)
Drop elements from the Stream until the predicate returns true, after
which all elements are included
|
default ReactiveSeq<T> |
skipUntilClosed(java.util.function.Predicate<? super T> p) |
ReactiveSeq<T> |
skipWhile(java.util.function.Predicate<? super T> p)
SkipWhile drops elements from the Stream while the predicate holds, once
the predicte returns true all subsequent elements are included *
|
ReactiveSeq<T> |
skipWhileClosed(java.util.function.Predicate<? super T> predicate) |
default ReactiveSeq<T> |
slice(long from,
long to) |
default ReactiveSeq<VectorX<T>> |
sliding(int windowSize)
Create a sliding view over this Sequence
|
ReactiveSeq<VectorX<T>> |
sliding(int windowSize,
int increment)
Create a sliding view over this Sequence
|
ReactiveSeq<T> |
sorted()
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7))); |
default ReactiveSeq<T> |
sorted(java.util.Comparator<? super T> c)
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
|
default <U extends java.lang.Comparable<? super U>> |
sorted(java.util.function.Function<? super T,? extends U> function) |
default <U> ReactiveSeq<T> |
sorted(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitAt(int where)
Split at supplied location
|
org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> |
splitAtHead()
Split a Stream at it's head (similar toNested headAndTail)
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitBy(java.util.function.Predicate<T> splitter)
Split reactiveStream at point where predicate no longer holds
|
java.util.Spliterator<T> |
spliterator()
Returns a spliterator for the elements of this reactiveStream.
|
boolean |
startsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Stream.of(1,2,3))) |
boolean |
startsWithIterable(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
|
default ReactiveSeq<T> |
subStream(int start,
int end)
Return a Stream with elements before the provided skip index removed,
and elements after the provided take index removed
|
default ReactiveSeq<T> |
take(long take)
assertThat(ReactiveSeq.of(4,3,6,7).take(2).toList(),equalTo(Arrays.asList(4,3)); |
default ReactiveSeq<T> |
takeRight(int num)
Generate a new Traversable that takes the specified number elements from the take of this Traversable
|
default ReactiveSeq<T> |
takeUntil(java.util.function.Predicate<? super T> p)
Generate a new Traversable that takes elements from this Traversable until the predicate holds
|
default ReactiveSeq<T> |
takeWhile(java.util.function.Predicate<? super T> p)
Generate a new Traversable that takes elements from this Traversable as long as the predicate holds
|
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
timestamp()
ReactiveSeq.of(1,2,3,4,5)
.timestamp()
.forEach(System.out::println)
|
default java.util.List<T> |
toList()
Collect the collectable into an
ArrayList . |
default java.util.Set<T> |
toSet()
Collect the collectable into a
LinkedHashSet . |
default <R> ReactiveSeq<R> |
trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
triplicate()
Triplicates a Stream Buffers intermediate values, leaders may change
positions so a limit can be safely applied toNested the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
triplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
static <U,T> ReactiveSeq<T> |
unfold(U seed,
java.util.function.Function<? super U,java.util.Optional<org.jooq.lambda.tuple.Tuple2<T,U>>> unfolder)
Unfold a function into a ReactiveSeq
|
<T> ReactiveSeq<T> |
unit(T unit) |
ReactiveSeq<T> |
unordered() |
static <T,U> org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<U>> |
unzip(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> sequence)
Unzip a zipped Stream
|
static <T1,T2,T3> org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>> |
unzip3(ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T1,T2,T3>> sequence)
Unzip a zipped Stream into 3
|
static <T1,T2,T3,T4> |
unzip4(ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T1,T2,T3,T4>> sequence)
Unzip a zipped Stream into 4
|
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
|
default ReactiveSeq<T> |
zip(java.util.function.BinaryOperator<Zippable<T>> combiner,
Zippable<T> app)
Combine two applicatives together using the provided BinaryOperator (Semigroup, Monoid and Reducer all
extend BinaryOperator - checkout Semigroups and Monoids for a large number of canned combinations).
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(java.lang.Iterable<? extends U> other)
Zip (combine) this Zippable with the supplied Iterable combining both into a Tuple2
|
default <U,R> ReactiveSeq<R> |
zip(java.lang.Iterable<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Iterable using the supplied combining function
|
<S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third)
zip 3 Streams into one
|
default <S,U,R> ReactiveSeq<R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Fn3<? super T,? super S,? super U,? extends R> fn3) |
<T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth)
zip 4 Streams into 1
|
default <T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn) |
default <U,R> ReactiveSeq<R> |
zipLatest(org.reactivestreams.Publisher<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipP(org.reactivestreams.Publisher<? extends U> other) |
default <U,R> ReactiveSeq<R> |
zipP(org.reactivestreams.Publisher<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Publisher, using the supplied combining function
|
<U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipS(java.util.stream.Stream<? extends U> other)
Zip 2 streams into one
|
<U,R> ReactiveSeq<R> |
zipS(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
default <R> ReactiveSeq<R> |
zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn) |
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
zipWithIndex()
Add an index toNested the current Stream
|
default <R> ReactiveSeq<R> |
zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn) |
default <R> ReactiveSeq<R> |
zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn) |
builder, flatMapToDouble, flatMapToInt, flatMapToLong, forEachOrdered, toArray, toArray
asFunction, foldFuture, foldLazy, foldTry, forEach, forEach, forEach, forEach, forEach, forEachSubscribe, forEachSubscribe, forEachSubscribe, runFuture, runLazy, toListX, toSetX, visit
collectors, commonPrefix, commonSuffix, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, maxBy, minBy, mode, sum, sumDouble, sumInt, sumLong, to, toMap, toMap, toString, toString
foldLeft, foldLeft, foldLeft, foldLeft
subscribe, traversable, unitIterator
groupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingT
static <T> ReactiveSeq<T> enqueued(java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>> sub)
ReactiveSeq<Integer> input = ReactiveSeq.enqueued(subscriber->{
listener.onEvent(subscriber::onNext);
listener.onError(susbscriber::onError);
closeListener.onEvent(subscriber::onClose);
});
T
- sub
- static <T> ReactiveSeq<T> enqueuedAll(java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>>... subs)
static <T> ReactiveSeq<T> enqueued(Queue<T> q, java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>> sub)
static <T> ReactiveSeq<T> enqueued(QueueFactory<T> factory, java.util.function.Consumer<? super org.reactivestreams.Subscriber<T>>... subs)
static com.aol.cyclops2.internal.stream.OneShotStreamX<java.lang.Integer> fromCharSequence(java.lang.CharSequence input)
input
- String toNested construct ReactiveSeq fromstatic ReactiveSeq<java.lang.Integer> ofInts(int... values)
values
- ints toNested populate Stream fromstatic java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> limitInts(long maxSize)
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> skipInts(long skip)
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> mapInts(java.util.function.IntUnaryOperator b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> filterInts(java.util.function.IntPredicate b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> flatMapInts(java.util.function.IntFunction<? extends java.util.stream.IntStream> b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Integer>,? extends ReactiveSeq<java.lang.Integer>> concatInts(ReactiveSeq<java.lang.Integer> b)
static ReactiveSeq<java.lang.Long> ofLongs(long... values)
values
- longs toNested populate Stream fromstatic java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> limitLongs(long maxSize)
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> skipLongs(long skip)
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> mapLongs(java.util.function.LongUnaryOperator b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> filterLongs(java.util.function.LongPredicate b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> flatMapLongs(java.util.function.LongFunction<? extends java.util.stream.LongStream> b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Long>,? extends ReactiveSeq<java.lang.Long>> concatLongs(ReactiveSeq<java.lang.Long> b)
static ReactiveSeq<java.lang.Double> ofDoubles(double... values)
values
- longs toNested populate Stream fromstatic java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> limitDouble(long maxSize)
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> skipDoubles(long skip)
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> mapDoubles(java.util.function.DoubleUnaryOperator b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> filterLongs(java.util.function.DoublePredicate b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> flatMapDoubles(java.util.function.DoubleFunction<? extends java.util.stream.DoubleStream> b)
static java.util.function.Function<? super ReactiveSeq<java.lang.Double>,? extends ReactiveSeq<java.lang.Double>> concatDoubles(ReactiveSeq<java.lang.Double> b)
static <T> ReactiveSeq<T> of(T value)
of
in interface java.util.stream.Stream<T>
value
- Value toNested construct ReactiveSeq fromstatic <T> ReactiveSeq<T> fromSpliterator(java.util.Spliterator<T> spliterator)
spliterator
- Spliterator toNested construct a Stream fromdefault ReactiveSeq<java.lang.Integer> ints(java.util.function.ToIntFunction<? super T> fn, java.util.function.Function<? super java.util.stream.IntStream,? extends java.util.stream.IntStream> mapper)
{@code ReactiveSeq.range(1, 1000) .ints(i->i,s->s.map(i->i*2).filter(i->i<500)) .size(), //249
fn
- mapper
- default <R> ReactiveSeq<R> jooλ(java.util.function.Function<? super org.jooq.lambda.Seq<T>,? extends org.jooq.lambda.Seq<R>> mapper)
default <R> R foldJooλ(java.util.function.Function<? super org.jooq.lambda.Seq<T>,? extends R> mapper)
default java.util.stream.IntStream mapToInt(java.util.function.ToIntFunction<? super T> fn)
mapToInt
in interface java.util.stream.Stream<T>
mapToInt
in interface Traversable<T>
default ReactiveSeq<java.lang.Long> longs(java.util.function.ToLongFunction<? super T> fn, java.util.function.Function<? super java.util.stream.LongStream,? extends java.util.stream.LongStream> mapper)
{@code ReactiveSeq.range(1, 1000) .longs(i->i.longValue(),s->s.map(i->i*2).filter(i->i<500)) .size(), //249
fn
- mapper
- default java.util.stream.LongStream mapToLong(java.util.function.ToLongFunction<? super T> fn)
mapToLong
in interface java.util.stream.Stream<T>
mapToLong
in interface Traversable<T>
default ReactiveSeq<java.lang.Double> doubles(java.util.function.ToDoubleFunction<? super T> fn, java.util.function.Function<? super java.util.stream.DoubleStream,? extends java.util.stream.DoubleStream> mapper)
{@code ReactiveSeq.range(1, 1000) .doubles(i->i.doubleValue(),s->s.map(i->i*2).filter(i->i<500)) .size(), //249
fn
- mapper
- default java.util.stream.DoubleStream mapToDouble(java.util.function.ToDoubleFunction<? super T> fn)
mapToDouble
in interface java.util.stream.Stream<T>
mapToDouble
in interface Traversable<T>
static <T> ReactiveSeq<T> fill(T t)
t
- Value toNested fill Stream with<R> ReactiveSeq<R> coflatMap(java.util.function.Function<? super ReactiveSeq<T>,? extends R> fn)
ReactiveSeq.of(1,2,3)
.map(i->i*2)
.coflatMap(s -> s.reduce(0,(a,b)->a+b))
//ReactiveSeq[12]
fn
- <T> ReactiveSeq<T> unit(T unit)
default <R> ReactiveSeq<R> parallel(java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> fn)
default <R> ReactiveSeq<R> parallel(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> fn)
default <R> R foldParallel(java.util.function.Function<? super java.util.stream.Stream<T>,? extends R> fn)
default <R> R foldParallel(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends R> fn)
<U> U foldRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends U> accumulator)
Folds
default void printOut()
Folds
default <U,R> ReactiveSeq<R> zip(java.lang.Iterable<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippable
default <U,R> ReactiveSeq<R> zipP(org.reactivestreams.Publisher<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippable
<U,R> ReactiveSeq<R> zipS(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippable
static <T1> ReactiveSeq<T1> flatten(ReactiveSeq<? extends ReactiveSeq<T1>> nested)
ReactiveSeq.of(Arrays.asList(1,2))
.toNested(ReactiveSeq::flatten));
//reactiveStream of (1, 2);
static <T1> ReactiveSeq<T1> flattenI(ReactiveSeq<? extends java.lang.Iterable<T1>> nested)
static <T1> ReactiveSeq<T1> flattenO(ReactiveSeq<? extends java.util.Optional<T1>> nested)
ReactiveSeq<T> cycle()
ReactiveSeq.of(1).cycle().limit(6).toList());
//List[1, 1, 1, 1, 1,1]
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicate()
Tuple2<ReactiveSeq<Integer>, ReactiveSeq<Integer>> copies = of(1, 2, 3, 4, 5, 6)
.duplicate();
assertTrue(copies.v1.anyMatch(i > i == 2));
assertTrue(copies.v2.anyMatch(i > i == 2));
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> triplicate()
Tuple3<ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>> Tuple3 = sequence.triplicate();
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> triplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> quadruplicate()
Tuple4<ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>> quad = sequence.quadruplicate();
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> quadruplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> splitAtHead()
ReactiveSeq.of(1,2,3)
.splitAtHead()
//Optional[1], ReactiveSeq[2,3]
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitAt(int where)
ReactiveSeq.of(1,2,3)
.splitAt(1)
//ReactiveSeq[1], ReactiveSeq[2,3]
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitBy(java.util.function.Predicate<T> splitter)
ReactiveSeq.of(1, 2, 3, 4, 5, 6).splitBy(i->i<4)
//ReactiveSeq[1,2,3] ReactiveSeq[4,5,6]
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> partition(java.util.function.Predicate<? super T> splitter)
ReactiveSeq.of(1, 2, 3, 4, 5, 6).partition(i -> i % 2 != 0)
//ReactiveSeq[1,3,5], ReactiveSeq[2,4,6]
default ReactiveSeq<T> cycle(Monoid<T> m, long times)
List<Integer> list = ReactiveSeq.of(1,2,2))
.cycle(Reducers.toCountInt(),3)
.collect(CyclopsCollectors.toList());
//List[3,3,3];
cycle
in interface Traversable<T>
m
- Monoid toNested be used in reductiontimes
- Number of times value should be repeateddefault ReactiveSeq<T> cycleWhile(java.util.function.Predicate<? super T> predicate)
MutableInt count = MutableInt.of(0);
ReactiveSeq.of(1, 2, 2).cycleWhile(next -> count++ < 6)
.collect(CyclopsCollectors.toList());
// List(1,2,2,1,2,2)
cycleWhile
in interface Traversable<T>
predicate
- repeat while truedefault ReactiveSeq<T> cycleUntil(java.util.function.Predicate<? super T> predicate)
MutableInt count =MutableInt.of(0);
ReactiveSeq.of(1,2,2)
.cycleUntil(next -> count.get()>6)
.peek(i-> count.mutate(i->i+1))
.collect(CyclopsCollectors.toList());
//List[1,2,2,1,2,2,1]
cycleUntil
in interface Traversable<T>
predicate
- repeat while true<U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zipS(java.util.stream.Stream<? extends U> other)
List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList();
// [[1,"a"],[2,"b"]]
default <U,R> ReactiveSeq<R> zipLatest(org.reactivestreams.Publisher<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zip(java.lang.Iterable<? extends U> other)
Zippable
<S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
List<Tuple3<Integer, Integer, Character>> list = of(1, 2, 3, 4, 5, 6).zip3(of(100, 200, 300, 400), of('a', 'b', 'c')).collect(CyclopsCollectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
<T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
List<Tuple4<Integer, Integer, Character, String>> list = of(1, 2, 3, 4, 5, 6).zip4(of(100, 200, 300, 400), of('a', 'b', 'c'), of("hello", "world"))
.collect(CyclopsCollectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]
default org.jooq.lambda.Seq<T> seq()
seq
in interface FoldableTraversable<T>
default ReactiveSeq<T> shuffle(java.util.Random random)
shuffle
in interface Traversable<T>
default ReactiveSeq<T> slice(long from, long to)
slice
in interface Traversable<T>
default <U extends java.lang.Comparable<? super U>> ReactiveSeq<T> sorted(java.util.function.Function<? super T,? extends U> function)
sorted
in interface Traversable<T>
default ReactiveSeq<T> shuffle()
shuffle
in interface Traversable<T>
default <U> U reduce(U identity, java.util.function.BiFunction<U,? super T,U> accumulator)
Folds
Stream.reduce(Object, BinaryOperator)
reduce
in interface Folds<T>
identity
- Identity value for the combiner function (leaves the input unchanged)accumulator
- Combiner functiondefault <U> ReactiveSeq<T> sorted(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> zipWithIndex()
assertEquals(asList(new Tuple2("a", 0L), new Tuple2("b", 1L)), of("a", "b").zipWithIndex().toList());
zipWithIndex
in interface Traversable<T>
default ReactiveSeq<VectorX<T>> sliding(int windowSize)
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).sliding(2).collect(CyclopsCollectors.toList());
assertThat(list.get(0), hasItems(1, 2));
assertThat(list.get(1), hasItems(2, 3));
sliding
in interface Traversable<T>
windowSize
- Size of sliding windowReactiveSeq<VectorX<T>> sliding(int windowSize, int increment)
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).sliding(3, 2).collect(CyclopsCollectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(3, 4, 5));
sliding
in interface Traversable<T>
windowSize
- number of elements in each batchincrement
- for each windowReactiveSeq<ListX<T>> grouped(int groupSize)
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).grouped(3).collect(CyclopsCollectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(4, 5, 6));
grouped
in interface Traversable<T>
groupSize
- Size of each GroupReactiveSeq<ListX<T>> groupedStatefullyUntil(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
ReactiveSeq.of(1,2,3,4,5,6)
.groupedStatefullyUntil((s,i)-> s.contains(4) ? true : false)
.toList()
.size()
//5
groupedStatefullyUntil
in interface Traversable<T>
predicate
- Window while true<C extends java.util.Collection<T>,R> ReactiveSeq<R> groupedStatefullyUntil(java.util.function.BiPredicate<C,? super T> predicate, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
ReactiveSeq<ListX<T>> groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
<C extends java.util.Collection<T>,R> ReactiveSeq<R> groupedStatefullyWhile(java.util.function.BiPredicate<C,? super T> predicate, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
ReactiveSeq<ListX<T>> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq.of(1,2,3,4,5,6)
.groupedBySizeAndTime(3,10,TimeUnit.SECONDS)
.toList();
//[[1,2,3],[4,5,6]]
size
- Max size of a batchtime
- (Max) time period toNested build a single batch int
- time unit for batch<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory)
ReactiveSeq.of(1,2,3,4,5,6)
.groupedBySizeAndTime(3,10,TimeUnit.SECONDS,()->SetX.empty())
.toList();
//[[1,2,3],[4,5,6]]
size
- Max size of a batchtime
- (Max) time period toNested build a single batch inunit
- time unit for batchfactory
- Collection factory<C extends java.util.Collection<? super T>,R> ReactiveSeq<R> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
<C extends java.util.Collection<? super T>,R> ReactiveSeq<R> groupedByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
ReactiveSeq<ListX<T>> groupedByTime(long time, java.util.concurrent.TimeUnit t)
assertThat(ReactiveSeq.of(1,2,3,4,5,6).batchByTime(1,TimeUnit.SECONDS).collect(CyclopsCollectors.toList()).size(),is(1));
assertThat(ReactiveSeq.of(1,2,3,4,5,6).batchByTime(1,TimeUnit.NANOSECONDS).collect(CyclopsCollectors.toList()).size(),greaterThan(5));
time
- - time period toNested build a single batch int
- time unit for batch<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchByTime(1500,TimeUnit.MICROSECONDS,()-> new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
time
- - time period toNested build a single batch inunit
- time unit for batchfactory
- Collection factory<C extends java.util.Collection<? super T>> ReactiveSeq<C> grouped(int size, java.util.function.Supplier<C> supplier)
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchBySize(3,()->new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
grouped
in interface Traversable<T>
size
- batch sizesupplier
- Collection factorydefault ReactiveSeq<ListX<T>> groupedUntil(java.util.function.Predicate<? super T> predicate)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3==0)
.toList()
.size(),equalTo(2));
groupedUntil
in interface Traversable<T>
predicate
- Batch until predicate holds, apply open next batchReactiveSeq<ListX<T>> groupedWhile(java.util.function.Predicate<? super T> predicate)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList().size(),equalTo(2));
groupedWhile
in interface Traversable<T>
predicate
- Batch while predicate holds, apply open next batch<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedWhile(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList()
.size(),equalTo(2));
groupedWhile
in interface Traversable<T>
predicate
- Batch while predicate holds, apply open next batchfactory
- Collection factorydefault <C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedUntil(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3!=0)
.toList()
.size(),equalTo(2));
groupedUntil
in interface Traversable<T>
predicate
- Batch until predicate holds, apply open next batchfactory
- Collection factorydefault <K,A,D> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,D>> grouped(java.util.function.Function<? super T,? extends K> classifier, java.util.stream.Collector<? super T,A,D> downstream)
Traversable
grouped
in interface Traversable<T>
classifier
- Grouping functiondownstream
- Collector toNested create the grouping collectiondefault <K> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,ReactiveSeq<T>>> grouped(java.util.function.Function<? super T,? extends K> classifier)
Traversable
grouped
in interface Traversable<T>
classifier
- Grouping functiondefault <K> MapX<K,ListX<T>> groupBy(java.util.function.Function<? super T,? extends K> classifier)
Map<Integer, List<Integer>> map1 = of(1, 2, 3, 4).groupBy(i -> i % 2);
assertEquals(asList(2, 4), map1.get(0));
assertEquals(asList(1, 3), map1.get(1));
assertEquals(2, map1.size());
ReactiveSeq<T> distinct()
distinct
in interface java.util.stream.Stream<T>
distinct
in interface Traversable<T>
default ReactiveSeq<T> scanLeft(Monoid<T> monoid)
assertEquals(asList("", "a", "ab", "abc"),ReactiveSeq.of("a", "b", "c")
.scanLeft(Reducers.toString("")).toList());
scanLeft
in interface Traversable<T>
monoid
- <U> ReactiveSeq<U> scanLeft(U seed, java.util.function.BiFunction<? super U,? super T,? extends U> function)
assertThat(of("a", "b", "c").scanLeft("", String::concat).toList().size(),
is(4));
scanLeft
in interface Traversable<T>
default ReactiveSeq<T> scanRight(Monoid<T> monoid)
assertThat(of("a", "b", "c").scanRight(Monoid.of("", String::concat)).toList().size(),
is(asList("", "c", "bc", "abc").size()));
scanRight
in interface Traversable<T>
default <U> ReactiveSeq<U> scanRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
assertThat(of("a", "ab", "abc").map(str->str.length()).scanRight(0, (t, u) -> u + t).toList().size(),
is(asList(0, 3, 5, 6).size()));
scanRight
in interface Traversable<T>
ReactiveSeq<T> sorted()
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7)));
sorted
in interface java.util.stream.Stream<T>
sorted
in interface Traversable<T>
default ReactiveSeq<T> combine(java.util.function.BiPredicate<? super T,? super T> predicate, java.util.function.BinaryOperator<T> op)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine((a, b)->a.equals(b),Semigroups.intSum)
.listX()
//ListX(3,4)
combine
in interface Traversable<T>
predicate
- Test toNested see if two neighbours should be joined. The first parameter toNested the bi-predicate is the currently
accumulated result and the second is the next elementop
- BinaryOperator toNested combine neighboursdefault ReactiveSeq<T> combine(Monoid<T> op, java.util.function.BiPredicate<? super T,? super T> predicate)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine(Monoids.intMult,(a, b)->a.equals(b))
.listX()
//ListX(1)
Simalar toNested @see Traversable.combine(BiPredicate, BinaryOperator)
but differs in that the first comparison is always toNested the Monoid zero
This allows us toNested terminate with just a single valuecombine
in interface Traversable<T>
op
- Monoid toNested combine neighbourspredicate
- Test toNested see if two neighbours should be joined. The first parameter toNested the bi-predicate is the currently
accumulated result and the second is the next elementdefault ReactiveSeq<T> sorted(java.util.Comparator<? super T> c)
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
sorted
in interface java.util.stream.Stream<T>
sorted
in interface Traversable<T>
c
- Compartor toNested sort withdefault ReactiveSeq<T> takeWhile(java.util.function.Predicate<? super T> p)
Traversable
ListX.of(1,2,3).takeWhile(i<3);
//[1,2]
takeWhile
in interface Traversable<T>
p
- Predicate toNested determine when values should be takendefault ReactiveSeq<T> drop(long drop)
Traversable
assertThat(ReactiveSeq.of(4,3,6,7).drop(2).toList(),equalTo(Arrays.asList(6,7)));
drop
in interface Traversable<T>
drop
- Number of elemenets toNested dropdefault ReactiveSeq<T> take(long take)
Traversable
assertThat(ReactiveSeq.of(4,3,6,7).take(2).toList(),equalTo(Arrays.asList(4,3));
take
in interface Traversable<T>
take
- Limit element size toNested numdefault ReactiveSeq<T> dropWhile(java.util.function.Predicate<? super T> p)
Traversable
ListX.of(1,2,3).dropWhile(i<3);
//[3]
dropWhile
in interface Traversable<T>
p
- Predicate toNested determine when values should be droppeddefault ReactiveSeq<T> takeUntil(java.util.function.Predicate<? super T> p)
Traversable
ListX.of(1,2,3).takeUntil(i<2);
//[1,2]
takeUntil
in interface Traversable<T>
p
- Predicate toNested determine when values should be taken untildefault ReactiveSeq<T> dropUntil(java.util.function.Predicate<? super T> p)
Traversable
ListX.of(1,2,3).dropUntil(i>2);
//[3]
dropUntil
in interface Traversable<T>
p
- Predicate toNested determine when values should be droppeddefault ReactiveSeq<T> dropRight(int num)
Traversable
ListX.of(1,2,3).dropRight(2);
//[1]
dropRight
in interface Traversable<T>
num
- Drop this number of elements from the take of this Traversabledefault ReactiveSeq<T> takeRight(int num)
Traversable
ListX.of(1,2,3).takeRight(2);
//[2,3]
takeRight
in interface Traversable<T>
num
- Take this number of elements from the take of this TraversableReactiveSeq<T> skip(long num)
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7)));
skip
in interface java.util.stream.Stream<T>
skip
in interface Traversable<T>
num
- Number of elemenets toNested skipvoid forEach(java.util.function.Consumer<? super T> action)
forEachAsync(Consumer)
and forEach overloads
such as FoldableTraversable.forEach(Consumer, Consumer)
and FoldableTraversable.forEach(Consumer, Consumer,Runnable)
This method overrides the JDK Stream.forEach(Consumer)
and maintains it's blocking
semantics. Other forEach overloads in ReactiveSeq are non-blocking for asynchronously executing Streams.
This is a terminal operation.
The behavior of this operation is explicitly nondeterministic. For parallel reactiveStream pipelines, this operation does not guarantee toNested respect the encounter order of the reactiveStream, as doing so would sacrifice the benefit of parallelism. For any given element, the action may be performed at whatever time and in whatever thread the library chooses. If the action accesses shared state, it is responsible for providing the required synchronization.
forEach
in interface java.lang.Iterable<T>
forEach
in interface java.util.stream.Stream<T>
action
- a
non-interfering action toNested perform on the elementsdefault void forEachAsync(java.util.function.Consumer<? super T> action)
forEach(java.util.function.Consumer<? super T>)
.
For push based reactive Stream types (created via Spouts or FutureStream)action
- a
non-interfering action toNested perform on the elementsReactiveSeq<T> skipWhile(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).sorted().skipWhile(i->i<6).toList(),equalTo(Arrays.asList(6,7)));
skipWhile
in interface Traversable<T>
p
- Predicate toNested skip while truedefault ReactiveSeq<T> skipUntil(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).skipUntil(i->i==6).toList(),equalTo(Arrays.asList(6,7)));
skipUntil
in interface Traversable<T>
p
- Predicate toNested skip until truedefault ReactiveSeq<T> skipUntilClosed(java.util.function.Predicate<? super T> p)
ReactiveSeq<T> limit(long num)
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3));
limit
in interface java.util.stream.Stream<T>
limit
in interface Traversable<T>
num
- Limit element size toNested numReactiveSeq<T> limitWhile(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).sorted().limitWhile(i->i<6).toList(),equalTo(Arrays.asList(3,4)));
limitWhile
in interface Traversable<T>
p
- Limit while predicate is trueReactiveSeq<T> limitUntil(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).limitUntil(i->i==6).toList(),equalTo(Arrays.asList(4,3)));
limitUntil
in interface Traversable<T>
p
- Limit until predicate is truedefault ReactiveSeq<T> limitUntilClosed(java.util.function.Predicate<? super T> p)
ReactiveSeq<T> parallel()
boolean allMatch(java.util.function.Predicate<? super T> c)
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
allMatch
in interface CyclopsCollectable<T>
allMatch
in interface java.util.stream.Stream<T>
c
- Predicate toNested check if all matchboolean anyMatch(java.util.function.Predicate<? super T> c)
assertThat(ReactiveSeq.of(1,2,3,4,5).anyMatch(it-> it.equals(3)),equalTo(true));
anyMatch
in interface CyclopsCollectable<T>
anyMatch
in interface java.util.stream.Stream<T>
c
- Predicate toNested check if any matchboolean xMatch(int num, java.util.function.Predicate<? super T> c)
assertTrue(ReactiveSeq.of(1,2,3,5,6,7).xMatch(3, i-> i>4 ));
boolean noneMatch(java.util.function.Predicate<? super T> c)
noneMatch
in interface CyclopsCollectable<T>
noneMatch
in interface java.util.stream.Stream<T>
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());
HeadAndTail<T> headAndTail()
FoldableTraversable
ReactiveSeq<String> helloWorld = ReactiveSeq.Of("hello","world","last");
HeadAndTail<String> headAndTail = helloWorld.headAndTail();
String head = headAndTail.head();
//head == "hello"
ReactiveSeq<String> tail = headAndTail.tail();
//["world","last]
headAndTail
in interface FoldableTraversable<T>
java.util.Optional<T> findFirst()
Maybe<T> findOne()
Either<java.lang.Throwable,T> findFirstOrError()
java.util.Optional<T> findAny()
default <R> ReactiveSeq<R> trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline
in interface Transformable<T>
mapper
- <R> R mapReduce(Reducer<R> reducer)
ReactiveSeq.of("hello","2","world","4").mapReduce(Reducers.toCountInt());
//4
<R> R mapReduce(java.util.function.Function<? super T,? extends R> mapper, Monoid<R> reducer)
ReactiveSeq.of("one","two","three","four")
.mapReduce(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;
}
T reduce(Monoid<T> reducer)
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
Folds
Stream.reduce(BinaryOperator)
ReactiveSeq.of(1,2,3,4,5).map(it -> it*100).reduce(
(acc,next) -> acc+next)
//Optional[1500]
T reduce(T identity, java.util.function.BinaryOperator<T> accumulator)
Folds
Stream.reduce(Object, BinaryOperator)
reduce
in interface Folds<T>
reduce
in interface java.util.stream.Stream<T>
accumulator
- Combiner functiondefault ReactiveSeq<T> reduceAll(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)
Folds
Stream.reduce(Object, BiFunction, BinaryOperator)
default <R> R collect(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super T> accumulator, java.util.function.BiConsumer<R,R> combiner)
ArrayList
, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent toNested:
R result = supplier.get();
for (T element : this reactiveStream)
accumulator.accept(result, element);
return result;
Like reduce(Object, BinaryOperator)
, collect
operations
can be parallelized without requiring additional synchronization.
This is a terminal operation.
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 functiondefault <R,A> ReactiveSeq<R> collectStream(java.util.stream.Collector<? super T,A,R> collector)
default <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
Collector
. A Collector
encapsulates the function used as arguments toNested
collect(Supplier, BiConsumer, BiConsumer)
, allowing for reuse of
collection strategies and composition of collect operations such as
multiple-level grouping or partitioning.
If the reactiveStream is parallel, and the Collector
is concurrent
, and
lazy the reactiveStream is unordered or the collector is
unordered
,
apply 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 toNested 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 CyclopsCollectable<T>
collect
in interface java.util.stream.Stream<T>
collector
- the Collector
describing the reductioncollect(Supplier, BiConsumer, BiConsumer)
,
Collectors
ListX<T> reduce(java.util.stream.Stream<? extends Monoid<T>> reducers)
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).reactiveStream());
assertThat(result, equalTo(Arrays.asList(10, 24)));
ListX<T> reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
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)));
T foldRight(Monoid<T> reducer)
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
T foldRight(T identity, java.util.function.BinaryOperator<T> accumulator)
assertTrue(ReactiveSeq.of("a","b","c").foldRight("", String::concat).equals("cba"));
<T> T foldRightMapToType(Reducer<T> reducer)
ReactiveSeq.of(1,2,3).foldRightMapToType(Reducers.toString(""));
// "321"
foldRightMapToType
in interface Folds<T>
reducer
- Monoid toNested reduce valuesdefault java.util.Set<T> toSet()
CyclopsCollectable
LinkedHashSet
.toSet
in interface CyclopsCollectable<T>
default java.util.List<T> toList()
CyclopsCollectable
ArrayList
.toList
in interface CyclopsCollectable<T>
ReactiveSeq<T> stream()
stream
in interface ExtendedTraversable<T>
stream
in interface FoldableTraversable<T>
stream
in interface Folds<T>
stream
in interface Sequential<T>
stream
in interface TransformerTraversable<T>
stream
in interface Traversable<T>
boolean startsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
startsWithIterable
in interface Folds<T>
iterable
- boolean startsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Stream.of(1,2,3)))
startsWith
in interface Folds<T>
stream
- AnyMSeq<Witness.reactiveSeq,T> anyM()
<R> ReactiveSeq<R> map(java.util.function.Function<? super T,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface FilterableTransformable<T>
map
in interface java.util.stream.Stream<T>
map
in interface Transformable<T>
fn
- Transformation functiondefault ReactiveSeq<T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek
in interface java.util.stream.Stream<T>
peek
in interface Transformable<T>
c
- Consumer that recieves each element from this Transformable<R> ReactiveSeq<R> flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
assertThat(ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i).reactiveStream())
.toList(),equalTo(asList(1, -1, 2, -2)));
flatMap
in interface java.util.stream.Stream<T>
fn
- toNested be applied<R> ReactiveSeq<R> flatMapAnyM(java.util.function.Function<? super T,AnyM<Witness.stream,? extends R>> fn)
assertThat(ReactiveSeq.of(1,2,3)).flatMapAnyM(i-> fromEither5(CompletableFuture.completedFuture(i+2))).toList(),equalTo(Arrays.asList(3,4,5)));
fn
- toNested be applied<R> ReactiveSeq<R> flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i))
.toList();
//1,-1,2,-2
fn
- <R> ReactiveSeq<R> flatMapP(int maxConcurrency, QueueFactory<R> factory, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
<R> ReactiveSeq<R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
<R> ReactiveSeq<R> flatMapP(int maxConcurrency, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
<R> ReactiveSeq<R> flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
assertThat(ReactiveSeq.of(1,2,3)
.flatMapStream(i->IntStream.of(i))
.toList(),equalTo(Arrays.asList(1,2,3)));
fn
- toNested be appliedReactiveSeq<T> filter(java.util.function.Predicate<? super T> fn)
Filters
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface FilterableTransformable<T>
filter
in interface Filters<T>
filter
in interface java.util.stream.Stream<T>
fn
- toNested filter elements by, retaining matchesjava.util.Spliterator<T> spliterator()
This is a terminal operation.
ReactiveSeq<T> sequential()
ReactiveSeq<T> unordered()
default ReactiveSeq<T> intersperse(T value)
intersperse
in interface Traversable<T>
default <U> ReactiveSeq<U> ofType(java.lang.Class<? extends U> type)
default <U> ReactiveSeq<U> cast(java.lang.Class<? extends U> type)
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast
in interface Transformable<T>
ReactiveSeq<T> reverse()
Traversable
assertThat( of(1, 2, 3).reverse().toList(),
equalTo(asList(3, 2, 1)));
reverse
in interface Traversable<T>
ReactiveSeq<T> onClose(java.lang.Runnable closeHandler)
ReactiveSeq<T> prependS(java.util.stream.Stream<? extends T> stream)
List<String> result = ReactiveSeq.of(1, 2, 3)
.prependS(of(100, 200, 300))
.map(it -> it + "!!")
.collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("100!!", "200!!", "300!!", "1!!", "2!!", "3!!")));
prependS
in interface Traversable<T>
stream
- toNested PrependReactiveSeq<T> append(T... values)
List<String> result = ReactiveSeq.of(1, 2, 3).append(100, 200, 300).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
append
in interface Traversable<T>
values
- toNested appendReactiveSeq<T> append(T value)
append
in interface Traversable<T>
ReactiveSeq<T> prepend(T value)
prepend
in interface Traversable<T>
ReactiveSeq<T> prepend(T... values)
List<String> result = ReactiveSeq.of(1,2,3)
.prepend(100,200,300)
.map(it ->it+"!!")
.collect(CyclopsCollectors.toList());
assertThat(result,equalTo(Arrays.asList("100!!","200!!","300!!","1!!","2!!","3!!")));
prepend
in interface Traversable<T>
values
- toNested prependdefault ReactiveSeq<T> insertAt(int pos, T... values)
List<String> result = ReactiveSeq.of(1, 2, 3).insertAt(1, 100, 200, 300).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!"))); *
insertAt
in interface Traversable<T>
pos
- toNested insert data atvalues
- toNested insertdefault ReactiveSeq<T> deleteBetween(int start, int end)
List<String> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).deleteBetween(2, 4).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "5!!", "6!!"))); *
deleteBetween
in interface Traversable<T>
start
- indexend
- indexdefault ReactiveSeq<T> insertAtS(int pos, java.util.stream.Stream<T> stream)
List<String> result = ReactiveSeq.of(1, 2, 3).insertAtS(1, of(100, 200, 300)).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!")));
insertAtS
in interface Traversable<T>
pos
- toNested insert Stream atstream
- toNested insertboolean endsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
endsWithIterable
in interface Folds<T>
iterable
- Values toNested checkboolean endsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Stream.of(5,6)));
ReactiveSeq<T> skip(long time, java.util.concurrent.TimeUnit unit)
List<Integer> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).peek(i -> sleep(i * 100)).skip(1000, TimeUnit.MILLISECONDS).toList();
// [4,5,6]
time
- Length of timeunit
- Time unitReactiveSeq<T> limit(long time, java.util.concurrent.TimeUnit unit)
List<Integer> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).peek(i -> sleep(i * 100)).limit(1000, TimeUnit.MILLISECONDS).toList();
// [1,2,3,4]
time
- Length of timeunit
- Time unitReactiveSeq<T> skipLast(int num)
skipLast
in interface Traversable<T>
num
- ReactiveSeq<T> limitLast(int num)
assertThat(ReactiveSeq.of(1,2,3,4,5)
.limitLast(2)
.collect(CyclopsCollectors.toList()),equalTo(Arrays.asList(4,5)));
limitLast
in interface Traversable<T>
num
- of elements toNested return (last elements)default HotStream<T> hotStream(java.util.concurrent.Executor e)
primedHotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see pausableHotStream(Executor)
.
Turns this ReactiveSeq into a HotStream, a connectable Stream, being
executed on a thread on the supplied executor, that is producing data
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE)
.hotStream(exec)
ints.connect().forEach(System.out::println);
//print out all the ints
//multiple consumers are possible, so other Streams can connect on different Threads
e
- Executor toNested execute this ReactiveSeq ondefault HotStream<T> primedHotStream(java.util.concurrent.Executor e)
hotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see primedPausableHotStream(Executor)
.
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE) .hotStream(exec) ints.connect().forEach(System.out::println); //print out all the ints - starting when connect is called. //multiple consumers are possible, so other Streams can connect on different Threads
e
- default PausableHotStream<T> pausableHotStream(java.util.concurrent.Executor e)
primedPausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream (slightly faster execution) @see hotStream(Executor)
.
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE)
.hotStream(exec)
ints.connect().forEach(System.out::println);
ints.pause(); //on a separate thread pause the generating Stream
//print out all the ints
//multiple consumers are possible, so other Streams can connect on different Threads
e
- Executor toNested execute this ReactiveSeq ondefault PausableHotStream<T> primedPausableHotStream(java.util.concurrent.Executor e)
pausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream @see primedHotStream(Executor)
.
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE) .hotStream(exec) ints.connect().forEach(System.out::println); //print out all the ints - starting when connect is called. //multiple consumers are possible, so other Streams can connect on different Threads
e
- T firstValue()
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
firstValue
in interface Folds<T>
default T single()
//1
ReactiveSeq.of(1).single();
//UnsupportedOperationException
ReactiveSeq.of().single();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).single();
default java.util.Optional<T> singleOptional()
//Optional[1]
ReactiveSeq.of(1).singleOptional();
//Optional.empty
ReactiveSeq.of().singleOpional();
//Optional.empty
ReactiveSeq.of(1,2,3).singleOptional();
singleOptional
in interface Folds<T>
default java.util.Optional<T> get(long index)
assertThat(ReactiveSeq.of(1,2,3,4,5).elementAt(2).get(),equalTo(3));
default org.jooq.lambda.tuple.Tuple2<T,ReactiveSeq<T>> elementAt(long index)
ReactiveSeq.of(1,2,3,4,5).get(2).v1
//3
index
- toNested extract element fromdefault ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> elapsed()
ReactiveSeq.of(1,2,3,4,5)
.elapsed()
.forEach(System.out::println);
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> timestamp()
ReactiveSeq.of(1,2,3,4,5)
.timestamp()
.forEach(System.out::println)
static <T> ReactiveSeq<T> empty()
empty
in interface java.util.stream.Stream<T>
static <T> ReactiveSeq<T> ofNullable(T nullable)
@SafeVarargs static <T> ReactiveSeq<T> of(T... elements)
of
in interface java.util.stream.Stream<T>
elements
- To Construct sequence from@SafeVarargs static <T> ReactiveSeq<T> reversedOf(T... elements)
elements
- To Construct sequence fromstatic <T> ReactiveSeq<T> reversedListOf(java.util.List<T> elements)
elements
- To Construct sequence fromstatic ReactiveSeq<java.lang.Integer> range(int start, int end)
start
- Number of range toNested skip fromend
- Number for range toNested take atstatic ReactiveSeq<java.lang.Long> rangeLong(long start, long end)
start
- Number of range toNested skip fromend
- Number for range toNested take atdefault boolean isReplayable()
static <T> ReactiveSeq<T> fromStream(java.util.stream.Stream<T> stream)
stream
- Stream toNested construct Sequence fromstatic <T> ReactiveSeq<T> oneShotStream(java.util.stream.Stream<T> stream)
static ReactiveSeq<java.lang.Integer> fromIntStream(java.util.stream.IntStream stream)
stream
- Stream toNested construct Sequence fromstatic ReactiveSeq<java.lang.Long> fromLongStream(java.util.stream.LongStream stream)
stream
- Stream toNested construct Sequence fromstatic ReactiveSeq<java.lang.Double> fromDoubleStream(java.util.stream.DoubleStream stream)
stream
- Stream toNested construct Sequence fromstatic <T> ReactiveSeq<T> fromList(java.util.List<T> list)
list
- toNested construct Sequence fromstatic <T> ReactiveSeq<T> oneShotList(java.util.List<T> list)
static <T> ReactiveSeq<T> fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
publisher
- toNested construct ReactiveSeq fromstatic <T> ReactiveSeq<T> fromIterable(java.lang.Iterable<T> iterable)
iterable
- toNested construct Sequence fromstatic <T> ReactiveSeq<T> reactiveSeq(java.lang.Iterable<T> iterable)
static <T> ReactiveSeq<T> fromIterator(java.util.Iterator<T> iterator)
iterator
- toNested construct Sequence fromstatic <T> ReactiveSeq<T> iterate(T seed, java.util.function.UnaryOperator<T> f)
iterate
in interface java.util.stream.Stream<T>
Stream.iterate(Object, UnaryOperator)
static <T> ReactiveSeq<T> iterate(T seed, java.util.function.Predicate<? super T> pred, java.util.function.UnaryOperator<T> f)
static <T> ReactiveSeq<T> deferredI(java.util.function.Supplier<? extends java.lang.Iterable<? extends T>> lazy)
static <T> ReactiveSeq<T> deferredP(java.util.function.Supplier<? extends org.reactivestreams.Publisher<? extends T>> lazy)
static <T> ReactiveSeq<T> deferred(java.util.function.Supplier<? extends java.util.stream.Stream<? extends T>> lazy)
static <U,T> ReactiveSeq<T> unfold(U seed, java.util.function.Function<? super U,java.util.Optional<org.jooq.lambda.tuple.Tuple2<T,U>>> unfolder)
ReactiveSeq.unfold(1,i->i<=6 ? Optional.of(Tuple.tuple(i,i+1)) : Optional.empty());
//(1,2,3,4,5)
seed
- Initial valueunfolder
- Iteratively applied function, terminated by an empty Optionalstatic <T> ReactiveSeq<T> generate(java.util.function.Supplier<T> s)
generate
in interface java.util.stream.Stream<T>
Stream.generate(Supplier)
static <T,U> org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<U>> unzip(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> sequence)
unzip(ReactiveSeq.of(new Tuple2(1, "a"), new Tuple2(2, "b"), new Tuple2(3, "c")))
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c]
static <T1,T2,T3> org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>> unzip3(ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T1,T2,T3>> sequence)
unzip3(ReactiveSeq.of(new Tuple3(1, "a", 2l), new Tuple3(2, "b", 3l), new Tuple3(3,"c", 4l)))
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c], ReactiveSeq[2l,3l,4l]
static <T1,T2,T3,T4> org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>,ReactiveSeq<T4>> unzip4(ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T1,T2,T3,T4>> sequence)
unzip4(ReactiveSeq.of(new Tuple4(1, "a", 2l,'µ'), new Tuple4(2, "b", 3l,'y'), new Tuple4(3,
"c", 4l,'x')));
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c], ReactiveSeq[2l,3l,4l], ReactiveSeq[µ,y,x]
ReactiveSeq<T> onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
assertThat(ReactiveSeq.of(4,5,6)
.onEmptySwitch(()->ReactiveSeq.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
onEmptySwitch
in interface OnEmptySwitch<T,java.util.stream.Stream<T>>
switchTo
- Supplier that will generate the alternative Streamdefault ReactiveSeq<T> onEmpty(T value)
OnEmpty
ReactiveSeq<T> onEmptyGet(java.util.function.Supplier<? extends T> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<T>
onEmptyGet
in interface Traversable<T>
supplier
- toNested determine new value for container<X extends java.lang.Throwable> ReactiveSeq<T> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
OnEmpty
onEmptyThrow
in interface OnEmpty<T>
onEmptyThrow
in interface Traversable<T>
supplier
- toNested create exception from<U> ReactiveSeq<T> distinct(java.util.function.Function<? super T,? extends U> keyExtractor)
ReactiveSeq<T> xPer(int x, long time, java.util.concurrent.TimeUnit t)
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 Sequential<T>
x
- number of elements toNested emittime
- periodt
- Time unitReactiveSeq<T> onePer(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq.iterate("", last -> "next")
.limit(100)
.batchBySize(10)
.onePer(1, TimeUnit.MICROSECONDS)
.peek(batch -> System.out.println("batched : " + batch))
.flatMap(Collection::reactiveStream)
.peek(individual -> System.out.println("Flattened : "
+ individual))
.forEach(a->{});
onePer
in interface Sequential<T>
time
- periodt
- Time unitReactiveSeq<T> debounce(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq.of(1,2,3,4,5,6)
.debounce(1000,TimeUnit.SECONDS).toList();
// 1
time
- Time toNested apply debouncing overt
- Time unit for debounce periodReactiveSeq<T> fixedDelay(long l, java.util.concurrent.TimeUnit unit)
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 Sequential<T>
l
- time length in nanos of the delayunit
- for the delayReactiveSeq<T> jitter(long maxJitterPeriodInNanos)
{ @code SimpleTimer timer = new SimpleTimer(); ReactiveSeq.of(1, 2, 3, 4, 5, 6) .jitter(10000) .collect(CyclopsCollectors.toList()); assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l)); }
maxJitterPeriodInNanos
- - random number less than this is used for each jitterReactiveSeq<T> recover(java.util.function.Function<? super java.lang.Throwable,? extends T> fn)
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
recover
in interface Traversable<T>
fn
- Function that accepts a Throwable and returns an alternative
value<EX extends java.lang.Throwable> ReactiveSeq<T> recover(java.lang.Class<EX> exceptionClass, java.util.function.Function<? super EX,? extends T> fn)
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(),equalTo("hello"));
recover
in interface Traversable<T>
exceptionClass
- Type toNested recover fromfn
- That accepts an error and returns an alternative valuedefault <R> ReactiveSeq<R> retry(java.util.function.Function<? super T,? extends R> fn)
given(serviceMock.apply(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock)
.firstValue();
//result = 42
retry
in interface Transformable<T>
fn
- Function toNested retry if failsdefault <R> ReactiveSeq<R> retry(java.util.function.Function<? super T,? extends R> fn, int retries, long delay, java.util.concurrent.TimeUnit timeUnit)
given(serviceMock.apply(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock, 7, 2, TimeUnit.SECONDS)
.firstValue();
//result = 42
retry
in interface Transformable<T>
fn
- Function toNested retry if failsretries
- Number of retriesdelay
- Delay in TimeUnitstimeUnit
- TimeUnit toNested use for delaydefault ReactiveSeq<T> remove(T t)
ReactiveSeq.of(1,2,3,4,5,1,2,3).remove(1)
//Streamable[2,3,4,5,2,3]
t
- element toNested removedefault ReactiveSeq<ReactiveSeq<T>> permutations()
permutations
in interface ExtendedTraversable<T>
default StreamT<Witness.reactiveSeq,T> permutationsT()
default ReactiveSeq<T> subStream(int start, int end)
ReactiveSeq.of(1,2,3,4,5,6).subStream(1,3);
//ReactiveSeq[2,3]
start
- index inclusiveend
- index exclusivedefault ReactiveSeq<ReactiveSeq<T>> combinations(int size)
ReactiveSeq.of(1,2,3).combinations(2)
//ReactiveSeq[ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]]
combinations
in interface ExtendedTraversable<T>
size
- of combinationsdefault StreamT<Witness.reactiveSeq,T> combinationsT(int size)
default <W extends WitnessType<W>> StreamT<W,T> liftM(W witness)
default ReactiveSeq<ReactiveSeq<T>> combinations()
ReactiveSeq.of(1,2,3).combinations()
//ReactiveSeq[ReactiveSeq[],ReactiveSeq[1],ReactiveSeq[2],ReactiveSeq[3].ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]
,ReactiveSeq[1,2,3]]
combinations
in interface ExtendedTraversable<T>
default StreamT<Witness.reactiveSeq,T> combinationsT()
default HotStream<T> schedule(java.lang.String cron, java.util.concurrent.ScheduledExecutorService ex)
//run at 8PM every night
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.schedule("0 20 * * *",Executors.newScheduledThreadPool(1));
Connect toNested the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.schedule("0 20 * * *", Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
default HotStream<T> scheduleFixedDelay(long delay, java.util.concurrent.ScheduledExecutorService ex)
//run every 60 seconds after last job completes
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedDelay(60_000,Executors.newScheduledThreadPool(1));
Connect toNested the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.scheduleFixedDelay(60_000, Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
scheduleFixedDelay
in interface Folds<T>
delay
- Between last element completes passing through the Stream
until the next one startsex
- ScheduledExecutorServicedefault HotStream<T> scheduleFixedRate(long rate, java.util.concurrent.ScheduledExecutorService ex)
//run every 60 seconds
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedRate(60_000,Executors.newScheduledThreadPool(1));
Connect toNested the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.scheduleFixedRate(60_000, Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
scheduleFixedRate
in interface Folds<T>
rate
- Time in millis between job runsex
- ScheduledExecutorServicedefault int size()
default <R1,R2,R3,R> ReactiveSeq<R> forEach4(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2, Fn3<? super T,? super R1,? super R2,? extends java.util.stream.BaseStream<R3,?>> stream3, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
//ReactiveSeq [1,2]
reactiveSeq.forEach4(a->ListX.range(10,13),
(a,b)->ListX.of(""+(a+b),"hello world"),
(a,b,c)->ListX.of(a,b,c)),
(a,b,c,d)->c+":"a+":"+b);
stream1
- Nested Stream toNested iterate overstream2
- Nested Stream toNested iterate overstream3
- Nested Stream toNested iterate overyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault <R1,R2,R3,R> ReactiveSeq<R> forEach4(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2, Fn3<? super T,? super R1,? super R2,? extends java.util.stream.BaseStream<R3,?>> stream3, Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
//ReactiveSeq [1,2,3]
seq.forEach4(a->ReactiveSeq.range(10,13),
(a,b)->Stream.of(""+(a+b),"hello world"),
(a,b,c)->Stream.of(a,b,c),
(a,b,c,d)-> c!=3,
(a,b,c)->c+":"a+":"+b);
stream1
- Nested Stream toNested iterate overstream2
- Nested Stream toNested iterate overstream3
- Nested Stream toNested iterate overfilterFunction
- Filter toNested apply over elements before passing non-filtered
values toNested the yielding functionyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault <R1,R2,R> ReactiveSeq<R> forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
ReactiveSeq.of(1,2)
.forEach3(a->IntStream.range(10,13),
(a,b)->Stream.of(""+(a+b),"hello world"),
(a,b,c)->c+":"a+":"+b);
//ReactiveSeq[11:1:2,hello world:1:2,14:1:4,hello world:1:4,12:1:2,hello world:1:2,15:1:5,hello world:1:5]
stream1
- Nested Stream toNested iterate overstream2
- Nested Stream toNested iterate overyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault <R1,R2,R> ReactiveSeq<R> forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,? extends java.util.stream.BaseStream<R2,?>> stream2, Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
ReactiveSeq.of(1,2,3)
.forEach3(a->IntStream.range(10,13),
(a,b)->Stream.of(""+(a+b),"hello world"),
(a,b,c)-> c!=3,
(a,b,c)->c+":"a+":"+b);
//ReactiveSeq[11:1:2,hello world:1:2,14:1:4,hello world:1:4,12:1:2,hello world:1:2,15:1:5,hello world:1:5]
stream1
- Nested Stream toNested iterate overstream2
- Nested Stream toNested iterate overfilterFunction
- Filter toNested apply over elements before passing non-filtered
values toNested the yielding functionyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault <R1,R> ReactiveSeq<R> forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(10,13),
(a,b)->a+b);
//ReactiveSeq[11,14,12,15,13,16]
stream1
- Nested Stream toNested iterate overyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> crossJoin(ReactiveSeq<? extends U> other)
other
- Stream toNested crossJoindefault <R1,R> ReactiveSeq<R> forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(10,13),
(a,b)-> a<3 && b>10,
(a,b)->a+b);
//ReactiveSeq[14,15]
stream1
- Nested Stream toNested iterate overfilterFunction
- Filter toNested apply over elements before passing non-filtered
values toNested the yielding functionyieldingFunction
- Function with pointers toNested the current element from both
Streams that generates the new elementsdefault java.util.Optional<T> max(java.util.Comparator<? super T> comparator)
CyclopsCollectable
max
in interface CyclopsCollectable<T>
max
in interface java.util.stream.Stream<T>
long count()
return mapToLong(e -> 1L).sum();
This is a terminal operation.
count
in interface CyclopsCollectable<T>
count
in interface java.util.stream.Stream<T>
default java.util.Optional<T> min(java.util.Comparator<? super T> comparator)
CyclopsCollectable
min
in interface CyclopsCollectable<T>
min
in interface java.util.stream.Stream<T>
default void printErr()
Folds
default void print(java.io.PrintWriter writer)
Folds
default void print(java.io.PrintStream stream)
Folds
ReactiveSeq<T> appendS(java.util.stream.Stream<? extends T> other)
List<String> result = ReactiveSeq.of(1, 2, 3).appendStream(ReactiveSeq.of(100, 200, 300)).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
stream
- toNested appendReactiveSeq<T> append(java.lang.Iterable<? extends T> other)
ReactiveSeq<T> prepend(java.lang.Iterable<? extends T> other)
ReactiveSeq<T> cycle(long times)
ReactiveSeq.of(1,2,2)
.cycle(3)
.collect(CyclopsCollectors.toList());
//List[1,2,2,1,2,2,1,2,2]
cycle
in interface Traversable<T>
times
- Times values should be repeated within a StreamReactiveSeq<T> skipWhileClosed(java.util.function.Predicate<? super T> predicate)
ReactiveSeq<T> limitWhileClosed(java.util.function.Predicate<? super T> predicate)
java.lang.String format()
default ReactiveSeq<T> removeAllS(java.util.stream.Stream<? extends T> stream)
IterableFilterable
removeAllS
in interface IterableFilterable<T>
stream
- of elements toNested removedefault ReactiveSeq<T> removeAllI(java.lang.Iterable<? extends T> it)
IterableFilterable
removeAllI
in interface IterableFilterable<T>
it
- an Iterable of elements toNested removedefault ReactiveSeq<T> removeAll(T... values)
IterableFilterable
removeAll
in interface IterableFilterable<T>
values
- toNested removedefault ReactiveSeq<T> retainAllI(java.lang.Iterable<? extends T> it)
IterableFilterable
retainAllI
in interface IterableFilterable<T>
it
- Iterable of elements toNested retaindefault ReactiveSeq<T> retainAllS(java.util.stream.Stream<? extends T> stream)
IterableFilterable
retainAllS
in interface IterableFilterable<T>
stream
- of elements toNested retaindefault ReactiveSeq<T> retainAll(T... values)
IterableFilterable
retainAll
in interface IterableFilterable<T>
values
- elements toNested retaindefault ReactiveSeq<T> filterNot(java.util.function.Predicate<? super T> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default ReactiveSeq<T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
default boolean isEmpty()
default ReactiveSeq<T> zip(java.util.function.BinaryOperator<Zippable<T>> combiner, Zippable<T> app)
Zippable
zip
in interface Zippable<T>
Semigroup
,
Semigroups
,
Monoid
,
To lift any Semigroup (or monoid) up toNested handling Applicatives use the combineApplicatives operator in Semigroups
{@see com.aol.cyclops2.Semigroups#combineApplicatives(BiFunction) } or Monoids
{ {@see com.aol.cyclops2.Monoids#combineApplicatives(java.util.function.Function, com.aol.cyclops2.function.Monoid)
}
{@code
BinaryOperator> sumMaybes = Semigroups.combineScalarFunctors(Semigroups.intSum);
Maybe.just(1).zip(sumMaybes, Maybe.just(5))
//Maybe.just(6));
}
default <R> ReactiveSeq<R> zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn)
default <R> ReactiveSeq<R> zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn)
default <R> ReactiveSeq<R> zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn)
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zipP(org.reactivestreams.Publisher<? extends U> other)
default <S,U,R> ReactiveSeq<R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Fn3<? super T,? super S,? super U,? extends R> fn3)
default <T2,T3,T4,R> ReactiveSeq<R> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth, Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn)
default ReactiveSeq<T> mergeP(org.reactivestreams.Publisher<T>... publishers)
IterableFunctor#mergePublisher(Collection, QueueFactory)
method toNested forEachAsync asynchronously also. Max concurrency is determined by the publishers collection size, along with a default limit of 5k queued values before
backpressure is applied.publishers
- Publishers toNested mergedefault ReactiveSeq<T> backpressureAware()
default ReactiveSeq<T> mergeP(QueueFactory<T> factory, org.reactivestreams.Publisher<T>... publishers)
QueueFactories
Push based reactive-streams signal demand via their subscription.default ReactiveSeq<T> publishTo(Adapter<T>... adapters)
default ReactiveSeq<T> publishTo(Signal<T>... signals)
default ReactiveSeq<T> merge(Adapter<T>... adapters)
default ListX<ReactiveSeq<T>> multicast(int num)
duplicate()
ReactiveSeq#triplate
quadruplicate()
Which buffer all Stream types and produce a synchronous downstream stream.num
- Number of downstream Streams toNested multicast toNesteddefault <R1,R2,R3> ReactiveSeq<R3> fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2, java.util.function.BiFunction<? super R1,? super R2,? extends R3> zipFn)
default <R1,R2,R3> ReactiveSeq<R3> parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2, java.util.function.BiFunction<? super R1,? super R2,? extends R3> zipFn)
default <R> ReactiveSeq<R> fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2)
default <R> ReactiveSeq<R> parallelFanOut(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2)
default <R> ReactiveSeq<R> fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path3)
default <R> ReactiveSeq<R> parallelFanOut(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path3)
default <R1,R2,R3,R4> ReactiveSeq<R4> parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R3>> path3, Fn3<? super R1,? super R2,? super R3,? extends R4> zipFn)
default <R1,R2,R3,R4> ReactiveSeq<R4> fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R3>> path3, Fn3<? super R1,? super R2,? super R3,? extends R4> zipFn)
default <R> ReactiveSeq<R> fanOut(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path2, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path3, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R>> path4)
default <R> ReactiveSeq<R> parallelFanOut(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path2, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path3, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R>> path4)
default <R1,R2,R3,R4,R5> ReactiveSeq<R5> fanOutZipIn(java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R1>> path1, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R2>> path2, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R3>> path3, java.util.function.Function<? super ReactiveSeq<T>,? extends ReactiveSeq<? extends R4>> path4, Fn4<? super R1,? super R2,? super R3,? super R4,? extends R5> zipFn)
default <R1,R2,R3,R4,R5> ReactiveSeq<R5> parallelFanOutZipIn(java.util.concurrent.ForkJoinPool fj, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R1>> path1, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R2>> path2, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R3>> path3, java.util.function.Function<? super java.util.stream.Stream<T>,? extends java.util.stream.Stream<? extends R4>> path4, Fn4<? super R1,? super R2,? super R3,? super R4,? extends R5> zipFn)
ReactiveSeq<T> changes()
default ReactiveSeq<T> ambWith(org.reactivestreams.Publisher<T> racer)
default ReactiveSeq<T> ambWith(org.reactivestreams.Publisher<T>... racers)
static <T> ReactiveSeq<T> concat(java.util.stream.Stream<? extends T>... streams)
static <T> ReactiveSeq<T> concat(java.util.Spliterator<? extends T>... array)
static <T> ReactiveSeq<T> concat(java.util.stream.Stream<? extends T> left, java.util.stream.Stream<? extends T> right)
concat
in interface java.util.stream.Stream<T>
static <T> ReactiveSeq<T> concat(java.util.Spliterator<? extends T> left, java.util.Spliterator<? extends T> right)
static <T> ReactiveSeq<T> narrowK(Higher<ReactiveSeq.µ,T> future)
future
- HKT encoded list into a ReactiveSeq