本文整理了Java中cyclops.reactive.ReactiveSeq.forEach2
方法的一些代码示例,展示了ReactiveSeq.forEach2
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.forEach2
方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:forEach2
[英]Perform a two level nested internal iteration over this Stream and the supplied stream
ReactiveSeq.of(1,2,3)
[中]在此流和提供的流上执行两级嵌套内部迭代
ReactiveSeq.of(1,2,3)
代码示例来源:origin: aol/cyclops
default Function2<ReactiveSeq<T1>,ReactiveSeq<T2>, ReactiveSeq<R>> streamM() {
return (a,b) -> a.forEach2(x->b,this);
}
default Function2<Future<T1>, Future<T2>, Future<R>> futureZip() {
代码示例来源:origin: aol/cyclops
/**
* crossJoin two Streams forming a cartesian zip over both
* @param other Stream to crossJoin
* @return Active Stream with each pair across both Streams in a Tuple
*/
default <U> ReactiveSeq<Tuple2<T, U>> crossJoin(ReactiveSeq<? extends U> other) {
return forEach2(a->other, Tuple::tuple);
}
代码示例来源:origin: aol/cyclops
@Test
public void forEach2(){
assertThat(ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(0,10),
(a,b)-> a+b)
.toList(),equalTo(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)));
}
代码示例来源:origin: aol/cyclops
@Test
public void forEach2Filter(){
assertThat(ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(0,10),
(a,b)->a>2 && b<8,
(a,b)-> a+b)
.toList(),equalTo(Arrays.asList(3,4,5,6,7,8,9,10)));
}
@Test
代码示例来源:origin: aol/cyclops
@Test
public void doGen2(){
ReactiveSeq.range(1,10)
.forEach2(i->range(0, i), (i,j)->tuple(i,j));
// .forEach(System.out::println);
}
代码示例来源:origin: com.oath.cyclops/cyclops-futurestream
@Override
default <R1, R> FutureStream<R> forEach2(Function<? super U, ? extends BaseStream<R1, ?>> stream1,
BiFunction<? super U, ? super R1, Boolean> filterFunction,
BiFunction<? super U, ? super R1, ? extends R> yieldingFunction) {
return (FutureStream<R>)ReactiveSeq.super.forEach2(stream1, filterFunction, yieldingFunction);
}
代码示例来源:origin: com.oath.cyclops/cyclops
/**
* crossJoin two Streams forming a cartesian zip over both
* @param other Stream to crossJoin
* @return Active Stream with each pair across both Streams in a Tuple
*/
default <U> ReactiveSeq<Tuple2<T, U>> crossJoin(ReactiveSeq<? extends U> other) {
return forEach2(a->other, Tuple::tuple);
}
代码示例来源:origin: com.oath.cyclops/cyclops-futurestream
@Override
default <R1, R> FutureStream<R> forEach2(Function<? super U, ? extends BaseStream<R1, ?>> stream1,
BiFunction<? super U, ? super R1, ? extends R> yieldingFunction) {
return (FutureStream<R>)ReactiveSeq.super.forEach2(stream1, yieldingFunction);
}
代码示例来源:origin: com.oath.cyclops/cyclops
default Function2<ReactiveSeq<T1>,ReactiveSeq<T2>, ReactiveSeq<R>> streamM() {
return (a,b) -> a.forEach2(x->b,this);
}
default Function2<Future<T1>, Future<T2>, Future<R>> futureZip() {
代码示例来源:origin: aol/cyclops
@Test
public void publishers(){
// import static com.oath.cyclops.control.For.*;
ReactiveSeq<Tuple2<Integer,Integer>> stream = ReactiveSeq.of(1,2,3).forEach2(i-> ReactiveSeq.range(i,5),
Tuple::tuple)
.stream();
stream.printOut();
/*
(1, 1)
(1, 2)
(1, 3)
(1, 4)
(2, 2)
(2, 3)
(2, 4)
(3, 3)
(3, 4)
*/
}
代码示例来源:origin: com.oath.cyclops/cyclops-futurestream
@Override
default <U1> FutureStream<Tuple2<U, U1>> crossJoin(ReactiveSeq<? extends U1> other) {
Streamable<? extends U1> s = Streamable.fromStream(other);
return fromStream(stream().forEach2(a->ReactiveSeq.fromIterable(s), Tuple::tuple));
}
内容来源于网络,如有侵权,请联系作者删除!