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

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

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

ReactiveSeq.fromList介绍

[英]Construct a ReactiveSeq from a List (prefer this method if the source is a list, as it allows more efficient Stream reversal).
[中]从列表构造一个ReactiveSeq(如果源是列表,则首选此方法,因为它允许更高效的流反转)。

代码示例

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

@Override
  public ReactiveSeq<T> next() {
    final List<T> result = new ArrayList<>(size);
    for (int idx : indices) {
      result.add((T)a[idx]);
    }
    if (++indices[size - 1] == toIndex) {
      for (int i = size - 1; i > 0; i--) {
        if (indices[i] > toIndex - (size - i)) {
          indices[i - 1]++;
          for (int j = i; j < size; j++) {
            indices[j] = indices[j - 1] + 1;
          }
        }
      }
    }
    return ReactiveSeq.fromList(result);
  }
};

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

private Option<ReactiveSeq<T>> first(){
  return indices.length>0 ? Option.some(ReactiveSeq.fromList(buildList())) : Option.none();
}
private Option<ReactiveSeq<T>> genNext() {

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

private Option<ReactiveSeq<T>> gen(int next) {
  return next<0 ? Option.none() : Option.some(ReactiveSeq.fromList(buildAndSwap(next)));
}
private void swapIndices(int i) {

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

@Test
public void limitList() throws InterruptedException{
  List<Integer> list= new ArrayList<>();
  for(int i=0;i<1000;i++)
    list.add(i);
  assertThat(ReactiveSeq.fromList(list)
       .limit(100)
       .count(),equalTo(100L));
}

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

@Test
public void testReverseList() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1))
          .reverse().toList(), equalTo(asList(-1, 2, 400,10)));
}
@Test

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

@Test
public void testReverseList() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1))
          .reverse().toList(), equalTo(asList(-1, 2, 400,10)));
}
@Test

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

@Test
public void testReverseList() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1))
      .reverse().toList(), equalTo(asList(-1, 2, 400,10)));
}
@Test

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

@Test
public void skipList() throws InterruptedException{
  List<Integer> list= new ArrayList<>();
  for(int i=0;i<1000;i++)
    list.add(i);
  assertThat(ReactiveSeq.fromList(list)
       .skip(100)
       .count(),equalTo(900L));
}
@Test

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

@Test
public void testReverseListLimit() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1)).limit(2)
          .reverse().toList(), equalTo(asList(400, 10)));
}
@Test

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

@Test
public void testReverseListLimit() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1)).limit(2)
          .reverse().toList(), equalTo(asList(400, 10)));
}
@Test

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

@Test
public void testReverseListLimitFirst() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1)).reverse().limit(2)
      .toList(), equalTo(asList(-1, 2)));
}

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

@Test
public void testReverseListLimit() {
  assertThat( ReactiveSeq.fromList(Arrays.asList(10,400,2,-1)).limit(2)
      .reverse().toList(), equalTo(asList(400, 10)));
}
@Test

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

@Override
  public ReactiveSeq<T> next() {
    final List<T> result = new ArrayList<>(size);
    for (int idx : indices) {
      result.add((T)a[idx]);
    }
    if (++indices[size - 1] == toIndex) {
      for (int i = size - 1; i > 0; i--) {
        if (indices[i] > toIndex - (size - i)) {
          indices[i - 1]++;
          for (int j = i; j < size; j++) {
            indices[j] = indices[j - 1] + 1;
          }
        }
      }
    }
    return ReactiveSeq.fromList(result);
  }
};

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

public <U> FutureStream<U> fromIterable(final Iterable<U> iter) {
  if(iter instanceof FutureStream){
    return (FutureStream<U>)iter;
  }
  final ReactiveSeq<U> seq = iter instanceof List ? ReactiveSeq.fromList((List) iter) : ReactiveSeq.fromIterable(iter);
  return this.fromStream(seq);
}

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

public <U> FutureStream<U> react(final Collection<Supplier<U>> actions) {
  final ReactiveSeq<Supplier<U>> seq = actions instanceof List ? ReactiveSeq.fromList((List) actions) : ReactiveSeq.fromIterable(actions);
  return fromStreamAsync(seq);
}

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

public <U> FutureStream<U> fromIterableAsync(final Iterable<? extends Supplier<U>> actions) {
  final ReactiveSeq<? extends Supplier<U>> seq = actions instanceof List ? ReactiveSeq.fromList((List) actions)
      : ReactiveSeq.fromIterable(actions);
  return this.<U> constructFutures(seq.map(next -> CompletableFuture.supplyAsync(next, getExecutor())));
}

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

private Option<ReactiveSeq<T>> first(){
  return indices.length>0 ? Option.some(ReactiveSeq.fromList(buildList())) : Option.none();
}
private Option<ReactiveSeq<T>> genNext() {

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

private Option<ReactiveSeq<T>> gen(int next) {
  return next<0 ? Option.none() : Option.some(ReactiveSeq.fromList(buildAndSwap(next)));
}
private void swapIndices(int i) {

相关文章

微信公众号

最新文章

更多

ReactiveSeq类方法