@Override public final <U> ReactiveSeq<U> scanLeft(final U seed, final BiFunction<? super U, ? super T, ? extends U> function) { Supplier<Function<? super T, ? extends Object>> scanLeft = () -> { Object[] current = {seed}; return in -> current[0] = function.apply((U) current[0], in); }; return createSeq(new ArrayConcatonatingOperator<>(new SingleValueOperator<U>(seed), extract((ReactiveSeq<U>) mapLazyFn(scanLeft)))); }
public static <T> ReactiveSeq<T> concat(Stream<? extends T>... streams){ Operator<T>[] operators = new Operator[streams.length]; int index = 0; Type async = Type.SYNC; for(Stream<T> next : (Stream<T>[])streams){ if(next instanceof ReactiveStreamX){ ReactiveStreamX rsx = ((ReactiveStreamX) next); operators[index] = rsx.getSource(); if(rsx.getType()== Type.BACKPRESSURE){ async = Type.BACKPRESSURE; } if(async== Type.SYNC && rsx.getType()== Type.NO_BACKPRESSURE){ async = Type.NO_BACKPRESSURE; } }else{ operators[index] = new SpliteratorToOperator<T>(next.spliterator()); } index++; } return new ReactiveStreamX<>(new ArrayConcatonatingOperator<T>(operators)).withAsync(async); }
public static <T> ReactiveSeq<T> concat(Publisher<Publisher<T>> pubs){ return reactiveStream(new ArrayConcatonatingOperator<T>(Spouts.from(pubs).seq() .map(p->new PublisherToOperator<T>(p)))); } public static <T> ReactiveSeq<T> lazyConcat(Publisher<Publisher<T>> pubs){
public Operator<Integer> createTwoAndError(){ return new ArrayConcatonatingOperator<>(new ArrayOfValuesOperator<>(), new SpliteratorToOperator<>(Stream.of(1).spliterator()), Fixtures.oneAndErrorSource); } public Operator<Integer> createThreeErrors(){
public Operator<Integer> createThreeErrors(){ return new ArrayConcatonatingOperator<>(new ArrayOfValuesOperator<>(), new SpliteratorToOperator<>(Stream.of().spliterator()), Fixtures.threeErrorsSource); }
public Operator<Integer> createOne(){ return new ArrayConcatonatingOperator<>(new ArrayOfValuesOperator<>(), new ArrayOfValuesOperator<>(1)); }
public Operator<Integer> createEmpty(){ return new ArrayConcatonatingOperator<>(new ArrayOfValuesOperator<>(),new ArrayOfValuesOperator<>()); } public Operator<Integer> createOne(){
public Operator<Integer> createThree(){ return new ArrayConcatonatingOperator<>(new ArrayOfValuesOperator<>(1), new ArrayOfValuesOperator<>(), new SpliteratorToOperator<>(Stream.of(2,3).spliterator())); /** return new ArrayConcatonatingOperator<>(new SpliteratorToOperator<>(Stream.of(1).spliterator()), new ArrayOfValuesOperator<>(), new ArrayOfValuesOperator<>(2,3));**/ } public Operator<Integer> createTwoAndError(){
@Override public final <U> ReactiveSeq<U> scanLeft(final U seed, final BiFunction<? super U, ? super T, ? extends U> function) { Supplier<Function<? super T, ? extends Object>> scanLeft = () -> { Object[] current = {seed}; return in -> current[0] = function.apply((U) current[0], in); }; return createSeq(new ArrayConcatonatingOperator<>(new SingleValueOperator<U>(seed), extract((ReactiveSeq<U>) mapLazyFn(scanLeft)))); }
public static <T> ReactiveSeq<T> concat(Stream<? extends T>... streams){ Operator<T>[] operators = new Operator[streams.length]; int index = 0; Type async = Type.SYNC; for(Stream<T> next : (Stream<T>[])streams){ if(next instanceof ReactiveStreamX){ ReactiveStreamX rsx = ((ReactiveStreamX) next); operators[index] = rsx.getSource(); if(rsx.getType()== Type.BACKPRESSURE){ async = Type.BACKPRESSURE; } if(async== Type.SYNC && rsx.getType()== Type.NO_BACKPRESSURE){ async = Type.NO_BACKPRESSURE; } }else{ operators[index] = new SpliteratorToOperator<T>(next.spliterator()); } index++; } return new ReactiveStreamX<>(new ArrayConcatonatingOperator<T>(operators)).withAsync(async); }
public static <T> ReactiveSeq<T> concat(Publisher<Publisher<T>> pubs){ return reactiveStream(new ArrayConcatonatingOperator<T>(Spouts.from(pubs).seq() .map(p->new PublisherToOperator<T>(p)))); } public static <T> ReactiveSeq<T> lazyConcat(Publisher<Publisher<T>> pubs){