cyclops.reactive.ReactiveSeq.forEach2()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中cyclops.reactive.ReactiveSeq.forEach2方法的一些代码示例,展示了ReactiveSeq.forEach2的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReactiveSeq.forEach2方法的具体详情如下:
包路径:cyclops.reactive.ReactiveSeq
类名称:ReactiveSeq
方法名:forEach2

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));
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法