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

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

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

ReactiveSeq.groupedWhile介绍

暂无

代码示例

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

@Override
default <C extends PersistentCollection<? super T>> ImmutableSortedSet<C> groupedWhile(Predicate<? super T> predicate, Supplier<C> factory) {
  return unitStream(stream().groupedWhile(predicate,factory));
}

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

@Override
default <C extends PersistentCollection<? super T>> ImmutableList<C> groupedWhile(Predicate<? super T> predicate, Supplier<C> factory) {
  return unitStream(stream().groupedWhile(predicate,factory));
}

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

@Override
default ImmutableSet<Vector<T>> groupedWhile(Predicate<? super T> predicate) {
  return unitStream(stream().groupedWhile(predicate));
}

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

@Test
public void windowWhile(){
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList().size(),equalTo(2));
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList().get(0),equalTo(Seq.of(1,2,3)));
}
@Test

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

@Test
public void groupedWhile(){
  assertThat(Spouts.iterate(0l, i->i+1l)
      .groupedWhile(i->false)
      .map(l->l.get(0))
      .limit(100)
      .collect(Collectors.toList()).size(),equalTo(100));
}
@Test

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

@Test
public void windowWhile(){
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList().size(),equalTo(2));
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList().get(0),equalTo(Seq.of(1,2,3)));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList()
      .size(),equalTo(2));
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void windowStatefullyWhile(){
  System.out.println(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile((s, i)->s.containsValue(4) ? true : false)
      .toList());
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile((s, i)->s.containsValue(4) ? true : false)
      .toList().size(),equalTo(4));
}
@Test

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

@Test
public void windowStatefullyWhile(){
  System.out.println(of(1,2,3,4,5,6)
      .groupedWhile((s, i)->s.containsValue(4) ? true : false)
      .toList());
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile((s, i)->s.containsValue(4) ? true : false)
      .toList().size(),equalTo(4));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList()
      .size(),equalTo(2));
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(Spouts.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList()
      .size(),equalTo(2));
  assertThat(Spouts.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList()
      .size(),equalTo(2));
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void windowStatefullyWhileEmpty(){
  assertThat(ReactiveSeq.of()
      .groupedWhile((s, i)->s.contains(4) ? true : false)
      .toList().size(),equalTo(0));
}
@Test

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

@Test
public void windowStatefullyWhileEmpty(){
  assertThat(of()
      .groupedWhile((s, i)->s.contains(4) ? true : false)
      .toList().size(),equalTo(0));
}
@Test

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

@Test
public void batchWhileCollection(){
  System.out.println("*"+of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList());
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList().size(),equalTo(2));
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhileCollection(){
  System.out.println("*"+of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList());
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList().size(),equalTo(2));
  assertThat(of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhileCollection(){
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList().size(),equalTo(2));
  assertThat(ReactiveSeq.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0,()->Vector.empty())
      .toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(Spouts.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .to(Streamable::fromStream).toList()
      .size(),equalTo(2));
  assertThat(Spouts.of(1,2,3,4,5,6)
      .groupedWhile(i->i%3!=0)
      .to(Streamable::fromStream).toList(),equalTo(Arrays.asList(Vector.of(1,2,3),Vector.of(4,5,6))));
}
@Test

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

@Test
public void batchWhile(){
  assertThat(of(1,2,3,4,5,6).stream().peek(System.out::println)
      .groupedWhile(i->true)
      .toList().get(0)
      .size(),equalTo(6));
}
@Test

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

@Override
public Publisher<Long> createPublisher(long elements) {
  return Spouts.iterate(0l, i->i+1l).groupedWhile(i->false).map(l->l.getOrElse(0,-1l)).limit(elements);
}

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法