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

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

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

ReactiveSeq.insertStreamAt介绍

[英]Insert a Stream into the middle of this stream at the specified position

List result = ReactiveSeq.of(1, 2, 3).insertAt(1, of(100, 200, 300)).map(it -> it + "!!").collect(CyclopsCollectors.toList());

[中]在该流的中间指定位置插入一个流

List result = ReactiveSeq.of(1, 2, 3).insertAt(1, of(100, 200, 300)).map(it -> it + "!!").collect(CyclopsCollectors.toList());

代码示例

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

@Override
default Streamable<T> insertStreamAt(int pos, Stream<T> stream){
  return fromStream(this.stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableQueue<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableList<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableSet<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableSortedSet<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream),comparator());
}

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

/**
 * Insert a Stream into the middle of this stream at the specified position
 * <pre>
 * {@code
 * List<String> result =     Streamable.of(1,2,3)
 *                                      .insertAt(1,of(100,200,300))
                   .map(it ->it+"!!")
                   .collect(CyclopsCollectors.toList());
    assertThat(result,equalTo(Arrays.asList("1!!","100!!","200!!","300!!","2!!","3!!")));
 * }
 * </pre>
 * @param pos to insert Stream at
 * @param stream to insert
 * @return newly conjoined Streamable
 */
default Streamable<T> insertStreamableAt(final int pos, final Streamable<T> stream) {
  return fromStream(this.stream().insertStreamAt(pos, stream.stream()));
}

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

@Test
public void insertAtSOutOfRangeEmpty() {
  for(int k=0;k<ITERATIONS;k++) {
    List<String> result = of().insertStreamAt(1, Stream.of(100, 200, 300))
        .map(it -> it + "!!").collect(Collectors.toList());
    assertThat(result, equalTo(Arrays.asList("100!!","200!!","300!!")));
  }
}
@Test

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

@Test
public void insertAtStreamEmpty() {
  for(int k=0;k<ITERATIONS;k++) {
    List<String> result = of().insertStreamAt(0, Stream.of(100, 200, 300))
        .map(it -> it + "!!").collect(Collectors.toList());
    assertThat(result, equalTo(Arrays.asList("100!!", "200!!", "300!!")));
  }
}

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

@Test
public void insertAtStreamOutOfRangeEmpty() {
  List<String> result = of().insertStreamAt(1, Stream.of(100, 200, 300))
      .map(it -> it + "!!").collect(Collectors.toList());
  assertThat(result, equalTo(Arrays.asList("100!!","200!!","300!!")));
}

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

@Test
public void insertAtStream() {
  for(int k=0;k<ITERATIONS;k++) {
    List<String> result = of(1, 2, 3).insertStreamAt(1, of(100, 200, 300))
        .map(it -> it + "!!").collect(Collectors.toList());
    assertThat(result, equalTo(Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!")));
  }
}

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

@Test
public void prependAppend(){
  assertThat(of(1)
      .prependStream(Stream.of(2)).append(3).prepend(4).appendAll(5,6)
      .prependAll(7,8)
      .insertAt(4,9).deleteBetween(1,2)
      .insertStreamAt(5,Stream.of(11,12)).stream().count(),equalTo(10L));
}
@Test

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

@Override
default ImmutableSet<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableList<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default Streamable<T> insertStreamAt(int pos, Stream<T> stream){
  return fromStream(this.stream().insertStreamAt(pos,stream));
}

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

@Override
default ImmutableQueue<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream));
}

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

@Override
default FutureStream<U> insertStreamAt(final int pos, final Stream<U> stream) {
  return fromStream(ReactiveSeq.oneShotStream(stream())
                 .insertStreamAt(pos, stream));
}

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

@Override
default ImmutableSortedSet<T> insertStreamAt(int pos, Stream<T> stream) {
  return unitStream(stream().insertStreamAt(pos,stream),comparator());
}

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

/**
 * Insert a Stream into the middle of this stream at the specified position
 * <pre>
 * {@code
 * List<String> result =     Streamable.of(1,2,3)
 *                                      .insertAt(1,of(100,200,300))
                   .map(it ->it+"!!")
                   .collect(CyclopsCollectors.toList());
    assertThat(result,equalTo(Arrays.asList("1!!","100!!","200!!","300!!","2!!","3!!")));
 * }
 * </pre>
 * @param pos to insert Stream at
 * @param stream to insert
 * @return newly conjoined Streamable
 */
default Streamable<T> insertStreamableAt(final int pos, final Streamable<T> stream) {
  return fromStream(this.stream().insertStreamAt(pos, stream.stream()));
}

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

/**
 * Insert a Stream into the middle of this stream at the specified position
 *
 * <pre>
 * {@code
 *   List<String> result =     of(1,2,3).actOnFutures()
                  .insertAt(1,of(100,200,300))
                  .map(it ->it+"!!")
                  .collect(CyclopsCollectors.toList());
    assertThat(result,equalTo(Arrays.asList("1!!","100!!","200!!","300!!","2!!","3!!")));
 * }
 * </pre>
 *
 * @param pos
 *            to insert Stream at
 * @param stream
 *            to insert
 * @return newly conjoined SequenceM
 */
default FutureStream<T> insertStreamAt(final int pos, final Stream<T> stream) {
  return fromStreamOfFutures(this.getLastActive()
                  .injectFuturesSeq()
                  .insertStreamAt(pos, stream.map(v -> FastFuture.completedFuture(v))));
}

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

/**
 * Insert a Stream into the middle of this stream at the specified position
 *
 * <pre>
 * {@code
     Stream<CompletableFuture<Integer>> streamOfFutures = Stream.of(CompletableFuture.completedFuture(100),CompletableFuture.completedFuture(200),CompletableFuture.completedFuture(300));
    List<String> result =     of(1,2,3).actOnFutures()
                .insertStreamFuturesAt(1,streamOfFutures)
                .map(it ->it+"!!")
                .collect(CyclopsCollectors.toList());
    assertThat(result,equalTo(Arrays.asList("1!!","100!!","200!!","300!!","2!!","3!!")));
  }
 * </pre>
 *
 * @param pos
 *            to insert Stream at
 * @param stream
 *            to insert
 * @return newly conjoined SequenceM
 */
default FutureStream<T> insertStreamFuturesAt(final int pos, final Stream<CompletableFuture<T>> stream) {
  return fromStreamOfFutures(this.getLastActive()
                  .injectFuturesSeq()
                  .insertStreamAt(pos, stream.map(v -> FastFuture.fromCompletableFuture(v))));
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法