本文整理了Java中cyclops.reactive.ReactiveSeq.fromSpliterator
方法的一些代码示例,展示了ReactiveSeq.fromSpliterator
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.fromSpliterator
方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:fromSpliterator
[英]Construct a ReactiveSeq from the Supplied Spliterator
[中]从提供的拆分器构造一个ReactiveSeq
代码示例来源:origin: aol/cyclops
/**
*
* @param values longs to populate Stream from
* @return ReactiveSeq of multiple Longs
*/
public static ReactiveSeq<Double> ofDoubles(double... values){
return fromSpliterator(new ReversingDoubleArraySpliterator<>(values,0,values.length,false));
}
代码示例来源:origin: aol/cyclops
/**
* @param values ints to populate Stream from
* @return ReactiveSeq of multiple Integers
*/
public static ReactiveSeq<Integer> ofInts(int... values){
return ReactiveSeq.fromSpliterator(new ReversingIntArraySpliterator<>(values,0,values.length,false));
}
/*
代码示例来源:origin: aol/cyclops
/**
* Efficiently construct a ReactiveSeq from a single value
*
* @param value Value to construct ReactiveSeq from
* @return ReactiveSeq of one value
*/
public static <T> ReactiveSeq<T> of(T value){
return fromSpliterator(new SingleSpliterator<>(value));
}
/**
代码示例来源:origin: aol/cyclops
/**
*
* @param values longs to populate Stream from
* @return ReactiveSeq of multiple Longs
*/
public static ReactiveSeq<Double> ofDoubles(double... values){
return ReactiveSeq.fromSpliterator(new ReversingDoubleArraySpliterator<>(values,0,values.length,false));
}
代码示例来源:origin: aol/cyclops
/**
* @param values ints to populate Stream from
* @return ReactiveSeq of multiple Integers
*/
public static ReactiveSeq<Integer> ofInts(int... values){
return fromSpliterator(new ReversingIntArraySpliterator<>(values,0,values.length,false));
}
/*
代码示例来源:origin: aol/cyclops
/**
* Construct a Stream consisting of a single value repeatedly infinitely (use take / drop etc to
* switch to a finite Stream)
*
* @param t Value to fill Stream with
* @return Infinite ReactiveSeq consisting of a single value
*/
public static <T> ReactiveSeq<T> fill(T t){
return ReactiveSeq.fromSpliterator(new FillSpliterator<T>(t));
}
/**
代码示例来源:origin: aol/cyclops
/**
*
* @param values longs to populate Stream from
* @return ReactiveSeq of multiple Longs
*/
public static ReactiveSeq<Long> ofLongs(long... values){
return fromSpliterator(new ReversingLongArraySpliterator<>(values,0,values.length,false));
}
代码示例来源:origin: aol/cyclops
default ReactiveSeq<T> stream() {
return ReactiveSeq.fromSpliterator(this.spliterator());
}
代码示例来源:origin: aol/cyclops
/**
* Unfold a function into a ReactiveSeq
*
* <pre>
* {@code
* ReactiveSeq.unfold(1,i->i<=6 ? Optional.of(Tuple.tuple(i,i+1)) : Optional.empty());
*
* //(1,2,3,4,5)
*
* }</code>
*
* @param seed Initial value
* @param unfolder Iteratively applied function, terminated by an empty Optional
* @return ReactiveSeq generated by unfolder function
*/
static <U, T> ReactiveSeq<T> unfold(final U seed, final Function<? super U, Option<Tuple2<T, U>>> unfolder) {
return ReactiveSeq.fromSpliterator(new UnfoldSpliterator<>(seed, unfolder));
}
代码示例来源:origin: aol/cyclops
/**
* 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 to an IntStream,
* otherwise the provided conversion function will be used.
*
* <pre>
* {@code
* ReactiveSeq.range(1, 1000)
* .ints(i->i,s->s.map(i->i*2).filter(i->i<500))
.size(),
//249
*
* </pre>
*
*
* @param fn
* @param mapper
* @return
*/
default ReactiveSeq<Integer> ints(ToIntFunction<? super T> fn,Function<? super IntStream, ? extends IntStream> mapper){
return ReactiveSeq.fromSpliterator(mapper.apply(mapToInt(fn)).spliterator());
}
代码示例来源:origin: aol/cyclops
@Override
public Spliterator<R> copy() {
if(in instanceof StreamX){
return new LazySingleSpliterator<>((X)ReactiveSeq.fromSpliterator(((StreamX)in).spliterator()), fn);
}else {
return new LazySingleSpliterator<>(in, fn);
}
}
}
代码示例来源:origin: aol/cyclops
@Deprecated //moved to cyclops.companion.Functions
public static Function<? super ReactiveSeq<Long>, ? extends ReactiveSeq<Long>> concatLongs( ReactiveSeq<Long> b){
return a->fromSpliterator(LongStream.concat(a.mapToLong(i->i),b.mapToLong(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
@Deprecated //moved to cyclops.companion.Functions
public static Function<? super ReactiveSeq<Integer>, ? extends ReactiveSeq<Integer>> concatInts( ReactiveSeq<Integer> b){
return a->fromSpliterator(IntStream.concat(a.mapToInt(i->i),b.mapToInt(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
@Deprecated //moved to cyclops.companion.Functions
public static Function<? super ReactiveSeq<Double>, ? extends ReactiveSeq<Double>> concatDoubles( ReactiveSeq<Double> b){
return a->fromSpliterator(DoubleStream.concat(a.mapToDouble(i->i),b.mapToDouble(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
public <R> ReactiveSeq<R> coflatMap(Function<? super ReactiveSeq<T>, ? extends R> fn){
return ReactiveSeq.fromSpliterator(new LazySingleSpliterator<T,ReactiveSeq<T>,R>(createSeq(copy()),fn));
}
代码示例来源:origin: aol/cyclops
public static Function<? super ReactiveSeq<Long>, ? extends ReactiveSeq<Long>> concatLongs( ReactiveSeq<Long> b){
return a->ReactiveSeq.fromSpliterator(LongStream.concat(a.mapToLong(i->i),b.mapToLong(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
public static Function<? super ReactiveSeq<Double>, ? extends ReactiveSeq<Double>> concatDoubles( ReactiveSeq<Double> b){
return a->ReactiveSeq.fromSpliterator(DoubleStream.concat(a.mapToDouble(i->i),b.mapToDouble(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
public static Function<? super ReactiveSeq<Integer>, ? extends ReactiveSeq<Integer>> concatInts( ReactiveSeq<Integer> b){
return a->ReactiveSeq.fromSpliterator(IntStream.concat(a.mapToInt(i->i),b.mapToInt(i->i)).spliterator());
}
代码示例来源:origin: aol/cyclops
@Test
public void replayStream(){
ReactiveSeq<String> stream = of("hello","world");
ReactiveSeq<String> stream1 = stream.map(str->"hello world " + str);
Spliterator<String> sp = stream1.spliterator();
ReactiveSeq.fromSpliterator(sp).forEach(System.out::println);
ReactiveSeq.fromSpliterator(sp).forEach(System.err::println);
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void replay(){
ReactiveSubscriber<String> pushable = Spouts.reactiveSubscriber();
ReactiveSeq<String> stream = pushable.reactiveStream();
ReactiveSeq<String> stream1 = stream.map(str->"hello world " + str);
Spliterator<String> sp = stream1.spliterator();
pushable.onNext("hello");
pushable.onComplete();
ReactiveSeq.fromSpliterator(sp).forEach(System.out::println);
pushable.onNext("world");
pushable.onComplete();
ReactiveSeq.fromSpliterator(sp).forEach(System.err::println);
}
@Test
内容来源于网络,如有侵权,请联系作者删除!