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

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

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

ReactiveSeq.zip4介绍

暂无

代码示例

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4, R> ImmutableQueue<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn) {
  return unitStream(stream().zip4(second,third,fourth,fn));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4> ImmutableSortedSet<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth) {
  return unitStream(stream().zip4(second,third,fourth));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4> ImmutableList<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth) {
  return unitStream(stream().zip4(second,third,fourth));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4, R> ImmutableSet<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn) {
  return unitStream(stream().zip4(second,third,fourth,fn));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4> ImmutableSet<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth) {
  return unitStream(stream().zip4(second,third,fourth));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4, R> ImmutableSortedSet<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn) {
  return unitStream(stream().zip4(second,third,fourth,fn));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4> ImmutableQueue<Tuple4<T, T2, T3, T4>> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth) {
  return unitStream(stream().zip4(second,third,fourth));
}

代码示例来源:origin: aol/cyclops

@Override
default <T2, T3, T4, R> ImmutableList<R> zip4(Iterable<? extends T2> second, Iterable<? extends T3> third, Iterable<? extends T4> fourth, Function4<? super T, ? super T2, ? super T3, ? super T4, ? extends R> fn) {
  return unitStream(stream().zip4(second,third,fourth,fn));
}

代码示例来源:origin: aol/cyclops

default <R1,R2,R3,R4,R5> ReactiveSeq<R5> fanOutZipIn(Function<? super ReactiveSeq<T>, ? extends ReactiveSeq<? extends R1>> path1,
                        Function<? super ReactiveSeq<T>, ? extends ReactiveSeq<? extends R2>> path2,
                        Function<? super ReactiveSeq<T>, ? extends ReactiveSeq<? extends R3>> path3,
                        Function<? super ReactiveSeq<T>, ? extends ReactiveSeq<? extends R4>> path4,
                        Function4<? super R1, ? super R2, ? super R3, ? super R4, ? extends R5> zipFn){
  Seq<ReactiveSeq<T>> list = multicast(4);
  return path1.apply(list.getOrElse(0,empty()))
        .zip4(path2.apply(list.getOrElse(1,empty())),
          path3.apply(list.getOrElse(2,empty())),
          path4.apply(list.getOrElse(3,empty())),
          zipFn);
}
default <R1,R2,R3,R4,R5> ReactiveSeq<R5> parallelFanOutZipIn(ForkJoinPool fj,Function<? super Stream<T>, ? extends Stream<? extends R1>> path1,

代码示例来源:origin: aol/cyclops

/**
 * zip 4 Streams into 1
 *
 * <pre>
 * {@code
 * 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"]]
 * </pre>
 */
default <T2, T3, T4> Streamable<Tuple4<T, T2, T3, T4>> zip4(final Streamable<? extends T2> second, final Streamable<? extends T3> third,
    final Streamable<? extends T4> fourth) {
  return fromStream(this.stream().zip4(second.stream(), third.stream(), fourth.stream()));
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = list.stream().map(t -> t._2()).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = list.stream().map(t -> t._1()).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = list.stream().map(t -> t._3()).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = list.stream().map(t -> t._4()).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = list.stream().map(t -> t._2()).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = list.stream().map(t -> t._1()).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = list.stream().map(t -> t._3()).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = list.stream().map(t -> t._4()).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: aol/cyclops

default <R1,R2,R3,R4,R5> ReactiveSeq<R5> parallelFanOutZipIn(ForkJoinPool fj,Function<? super Stream<T>, ? extends Stream<? extends R1>> path1,
                           Function<? super Stream<T>, ? extends Stream<? extends R2>> path2,
                           Function<? super Stream<T>, ? extends Stream<? extends R3>> path3,
                           Function<? super Stream<T>, ? extends Stream<? extends R4>> path4,
                           Function4<? super R1, ? super R2, ? super R3, ? super R4, ? extends R5> zipFn){
  val d = quadruplicate(()->new ArrayDeque<T>(100));
  ReactiveSeq<R1> res1 = d._1().parallel(fj, path1);
  ReactiveSeq<R2> res2 = d._2().parallel(fj, path2);
  ReactiveSeq<R3> res3 = d._3().parallel(fj, path3);
  ReactiveSeq<R4> res4 = d._4().parallel(fj, path4);
  return res1.zip4(res2,res3,res4,zipFn);
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = list.stream().map(t -> t._2()).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = list.stream().map(t -> t._1()).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = list.stream().map(t -> t._3()).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = list.stream().map(t -> t._4()).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = list.stream().map(t -> t._2()).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = list.stream().map(t -> t._1()).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = list.stream().map(t -> t._3()).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = list.stream().map(t -> t._4()).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = list.stream().map(t -> t._2()).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = list.stream().map(t -> t._1()).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = list.stream().map(t -> t._3()).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = list.stream().map(t -> t._4()).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: aol/cyclops

@Test
public void zip4(){
  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"))
                      .peek(it -> System.out.println(it))
                      .to(Streamable::fromStream).collect(Collectors.toList());
  System.out.println(list);
  List<Integer> right = Spouts.fromIterable(list).map(t -> t._2()).to(Streamable::fromStream).collect(Collectors.toList());
  assertThat(right,hasItem(100));
  assertThat(right,hasItem(200));
  assertThat(right,not(hasItem(300)));
  assertThat(right,not(hasItem(400)));
  List<Integer> left = Spouts.fromIterable(list).map(t -> t._1()).to(Streamable::fromStream).collect(Collectors.toList());
  assertThat(Arrays.asList(1,2,3,4,5,6),hasItem(left.get(0)));
  List<Character> three = Spouts.fromIterable(list).map(t -> t._3()).to(Streamable::fromStream).collect(Collectors.toList());
  assertThat(Arrays.asList('a','b','c'),hasItem(three.get(0)));
  List<String> four = Spouts.fromIterable(list).map(t -> t._4()).to(Streamable::fromStream).collect(Collectors.toList());
  assertThat(Arrays.asList("hello","world"),hasItem(four.get(0)));
}

代码示例来源:origin: com.oath.cyclops/cyclops-futurestream

@Override
default <T2, T3, T4, R> FutureStream<R> zip4(final Iterable<? extends T2> second, final Iterable<? extends T3> third, final Iterable<? extends T4> fourth, final Function4<? super U, ? super T2, ? super T3, ? super T4, ? extends R> fn) {
  return fromStream(stream().zip4(second,third,fourth,fn));
}

代码示例来源:origin: com.oath.cyclops/cyclops-futurestream

@Override
default <T2, T3, T4> FutureStream<Tuple4<U, T2, T3, T4>> zip4(final Iterable<? extends T2> second, final Iterable<? extends T3> third,
                               final Iterable<? extends T4> fourth) {
  return fromStream(ReactiveSeq.oneShotStream(stream())
                 .zip4(second, third, fourth));
}

代码示例来源:origin: com.oath.cyclops/cyclops

default <R1,R2,R3,R4,R5> ReactiveSeq<R5> parallelFanOutZipIn(ForkJoinPool fj,Function<? super Stream<T>, ? extends Stream<? extends R1>> path1,
                           Function<? super Stream<T>, ? extends Stream<? extends R2>> path2,
                           Function<? super Stream<T>, ? extends Stream<? extends R3>> path3,
                           Function<? super Stream<T>, ? extends Stream<? extends R4>> path4,
                           Function4<? super R1, ? super R2, ? super R3, ? super R4, ? extends R5> zipFn){
  val d = quadruplicate(()->new ArrayDeque<T>(100));
  ReactiveSeq<R1> res1 = d._1().parallel(fj, path1);
  ReactiveSeq<R2> res2 = d._2().parallel(fj, path2);
  ReactiveSeq<R3> res3 = d._3().parallel(fj, path3);
  ReactiveSeq<R4> res4 = d._4().parallel(fj, path4);
  return res1.zip4(res2,res3,res4,zipFn);
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法