java.util.stream.IntStream.sequential()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(181)

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

IntStream.sequential介绍

暂无

代码示例

代码示例来源:origin: speedment/speedment

@Override
public IntStream sequential() {
  return wrap(stream().sequential());
}

代码示例来源:origin: se.ugli.ugli-commons/ugli-commons

@Override
public IntStream sequential() {
  return new IntResourceStream(stream.sequential(), closeOnTerminalOperation, resources);
}

代码示例来源:origin: net.dongliu/commons-lang

@Override
public ExIntStream sequential() {
  return ExIntStream.of(stream.sequential());
}

代码示例来源:origin: stackoverflow.com

import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Accumulator {
  public static LongStream toCumulativeSumStream(IntStream ints){
    AtomicLong sum = new AtomicLong(0);
    return ints.sequential().mapToLong(sum::addAndGet);
  }

  public static void main(String[] args){
    LongStream sums = Accumulator.toCumulativeSumStream(IntStream.range(1, 5));
    sums.forEachOrdered(System.out::println);
  }
}

代码示例来源:origin: com.speedment.runtime/runtime-core

@Override
public IntStream sequential() {
  return wrap(stream().sequential());
}

代码示例来源:origin: stackoverflow.com

public class StreamExercise {
  public static void main(String[] args) {
    f(IntStream.range(0, 6))
      .forEach(s -> System.out.println(s));

    System.out.println();

    f(IntStream.of(1,3,5,7,9))
      .forEach(s -> System.out.println(s));
  }

  private static Stream<String> f(IntStream input) {
    IntFunction<String> mapper = new IntFunction<String>() {
      private int last = -1;

      @Override
      public String apply(int value) {
        String result = last + ", " + value;
        last = value;
        return result;
      }

    };

    return input.sequential().mapToObj(mapper).skip(1);
  }
}

代码示例来源:origin: stackoverflow.com

public static void sort(int[] A, int p, int r) {
  if (p < r) {
    int q = r - 1;
    sort(A, p, q);
    combine(A, p, q, r);
  }
}

private static void combine(int[] A, int p, int q, int r) {
  int i = q - p;
  int val = A[r];
  while (i >= 0 && val < A[p + i]) {
    A[p + i + 1] = A[p + i];
    A[p + i] = val;
    i--;
  }
}

public static void main(String... strings) {
  int[] A = { 2, 5, 3, 1, 7 };
  sort(A, 0, A.length - 1);
  Arrays.stream(A).sequential().forEach(i -> System.out.print(i + ", "));
}

相关文章