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

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

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

ReactiveSeq.fromIterator介绍

[英]Construct a ReactiveSeq from an Iterator
[中]从迭代器构造一个ReactiveSeq

代码示例

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

@Override
public ReactiveSeq<U> stream() {
  return ReactiveSeq.fromIterator(reversedIterator());
}

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

@Test
public void map(){
  Four<Integer> two = create(2,2,2, 2);
  Four<Integer> mapped = two.map(i->i*100);
  System.out.println(Arrays.deepToString(two.array));
  System.out.println(Arrays.deepToString(mapped.array));
  assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),equalTo(Arrays.asList(0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500)));
}
@Test

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

@Test
public void map(){
  Two<Integer> two = create(2,2);
  Two<Integer> mapped = two.map(i->i*100);
  System.out.println(Arrays.deepToString(two.array));
  System.out.println(Arrays.deepToString(mapped.array));
  assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),equalTo(Arrays.asList(0,100,200,300)));
}
@Test

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

@Test
public void map(){
  Three<Integer> two = create(2,2,2);
  Three<Integer> mapped = two.map(i->i*100);
  System.out.println(Arrays.deepToString(two.array));
  System.out.println(Arrays.deepToString(mapped.array));
  assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),equalTo(Arrays.asList(0,100,200,300,400,500,600,700)));
}
@Test

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

@Test
public void dynamic(){
  for(int i=0;i<20;i++) {
    Four<Integer> two = create(i, i,i,i);
    Four<Integer> mapped = two.map(n -> n * 100);
    System.out.println(Arrays.deepToString(two.array));
    System.out.println(Arrays.deepToString(mapped.array));
    assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),
      equalTo(ReactiveSeq.iterate(0,n->n+100).take(i*i*i*i).toList()));
  }
}

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

@Test
public void dynamic(){
  for(int i=0;i<20;i++) {
    Three<Integer> two = create(i, i,i);
    Three<Integer> mapped = two.map(n -> n * 100);
    System.out.println(Arrays.deepToString(two.array));
    System.out.println(Arrays.deepToString(mapped.array));
    assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),
      equalTo(ReactiveSeq.iterate(0,n->n+100).take(i*i*i).toList()));
  }
}

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

@Test
public void map(){
  Five<Integer> two = create(2,2,2, 2,2);
  Five<Integer> mapped = two.map(i->i*100);
  System.out.println(Arrays.deepToString(two.array));
  System.out.println(Arrays.deepToString(mapped.array));
  assertThat(ReactiveSeq.fromIterator(mapped.iterator()).seq(),equalTo(ReactiveSeq.range(0,32).map(i->i*100).seq()));
}
@Test

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

@Test
public void dynamic(){
  for(int i=0;i<20;i++) {
    Five<Integer> two = create(i, i,i,i,i);
    Five<Integer> mapped = two.map(n -> n * 100);
    System.out.println(Arrays.deepToString(two.array));
    System.out.println(Arrays.deepToString(mapped.array));
    assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),
      equalTo(ReactiveSeq.iterate(0,n->n+100).take(i*i*i*i*i).toList()));
  }
}

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

@Test
public void map(){
  Six<Integer> two = create(2,2,2, 2,2,2);
  Six<Integer> mapped = two.map(i->i*100);
  System.out.println(Arrays.deepToString(two.array));
  System.out.println(Arrays.deepToString(mapped.array));
  assertThat(ReactiveSeq.fromIterator(mapped.iterator()).seq(),equalTo(ReactiveSeq.range(0,64).map(i->i*100).seq()));
}
@Test

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

@Test
public void dynamic(){
  for(int i=0;i<100;i++) {
    Two<Integer> two = create(i, i);
    Two<Integer> mapped = two.map(n -> n * 100);
    System.out.println(Arrays.deepToString(two.array));
    System.out.println(Arrays.deepToString(mapped.array));
    assertThat(ReactiveSeq.fromIterator(mapped.iterator()).toList(),
      equalTo(ReactiveSeq.iterate(0,n->n+100).take(i*i).toList()));
  }
}

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

@Test
public void publishAndSubscribeIterator(){
  assertThat(ReactiveSeq.fromIterator(Spouts.from(ReactiveSeq.of(1,2,3)).iterator()).toList(),equalTo(
      Arrays.asList(1,2,3)));
}
@Test

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

@Test
  public void publishAndSubscribeEmptyIterator(){

    assertThat(ReactiveSeq.fromIterator(Spouts.from(ReactiveSeq.of()).iterator()).toList(),equalTo(
        Arrays.asList()));
  }
}

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

@Test
public void batchBySizeAndTimeSizeCollectionIterator(){
  Iterator<Vector<Integer>> it = of(1, 2, 3, 4, 5, 6)
      .groupedBySizeAndTime(3, 10, TimeUnit.SECONDS, () -> Vector.empty()).iterator();
  assertThat(ReactiveSeq.fromIterator(it)
      .toList().get(0)
      .size(),is(3));
}
@Test

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

@Test
public void batchBySizeAndTimeSizeCollectionIterator(){
  Iterator<Vector<Integer>> it = of(1, 2, 3, 4, 5, 6)
      .groupedBySizeAndTime(3, 10, TimeUnit.SECONDS, () -> Vector.empty()).iterator();
  assertThat(ReactiveSeq.fromIterator(it)
      .toList().get(0)
      .size(),is(3));
}
@Test

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

@Test
public void batchBySizeAndTimeSizeCollectionIterator(){
  Iterator<Vector<Integer>> it = of(1, 2, 3, 4, 5, 6)
      .groupedBySizeAndTime(3, 10, TimeUnit.SECONDS, () -> Vector.empty()).iterator();
  assertThat(ReactiveSeq.fromIterator(it)
      .toList().get(0)
      .size(),is(3));
}
@Test

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

@Test
public void batchBySizeAndTimeSizeCollectionIterator(){
  Iterator<Vector<Integer>> it = of(1, 2, 3, 4, 5, 6)
      .groupedBySizeAndTime(3, 10, TimeUnit.SECONDS, () -> Vector.empty()).iterator();
  assertThat(ReactiveSeq.fromIterator(it)
      .toList().get(0)
      .size(),is(3));
}
@Test

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

@Test
public void batchBySizeAndTimeSizeCollectionIterator(){
  Iterator<Vector<Integer>> it = of(1, 2, 3, 4, 5, 6)
      .groupedBySizeAndTime(3, 10, TimeUnit.SECONDS, () -> Vector.empty()).iterator();
  assertThat(ReactiveSeq.fromIterator(it)
      .to(Streamable::fromStream).toList().get(0)
      .size(),is(3));
}
@Test

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

@Test
public void flatMapPubIteration(){
  Iterator<Integer> it = of(1,2,3,4)
      .mergeMap(i->of(5,6)
          .mergeMap(k->of(k)))
      .iterator();
  assertThat(ReactiveSeq.fromIterator(it).size(),equalTo(8));
}
@Test

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

@Test
public void slidingWithSmallWindowAtEndIterative() {
  Iterator<Seq<Integer>> it =  ReactiveSeq.of(1, 2, 3, 4, 5).sliding(2,2).iterator();
  List<Seq<Integer>> sliding = ReactiveSeq.fromIterator(it).toList();
  assertThat(sliding, contains(Seq.of(1, 2), Seq.of(3, 4), Seq.of(5)));
}

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

@Test
public void slidingWithSmallWindowAtEndIterative() {
  Iterator<Seq<Integer>> it =  of(1, 2, 3, 4, 5).sliding(2,2).iterator();
  List<Seq<Integer>> sliding = ReactiveSeq.fromIterator(it).toList();
  assertThat(sliding, contains(Seq.of(1, 2), Seq.of(3, 4), Seq.of(5)));
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法