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

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

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

IntStream.iterator介绍

暂无

代码示例

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

@Override
  public PrimitiveIterator.OfInt execute() {
    try (final IntStream stream = buildPrevious()) {
      return stream.iterator();
    }
  }
}

代码示例来源:origin: SonarSource/sonarqube

PartiallyFailingIndexer(IndexType indexType, int... successfulReturns) {
 this.indexType = indexType;
 this.successfulReturns = IntStream.of(successfulReturns).iterator();
}

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

default PrimitiveIterator.OfInt iterator(IntPipeline pipeline) {
  requireNonNull(pipeline);
  return optimize(pipeline).getAsIntStream().iterator();
}

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

return IntStream.of( (int[]) o ).iterator();

代码示例来源:origin: prestodb/presto

PrimitiveIterator.OfInt iterator = s.codePoints().iterator();
while (iterator.hasNext()) {
  int codePoint = iterator.nextInt();

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

public final class RandomNumberGenerator {

  private PrimitiveIterator.OfInt randomIterator;

  /**
   * Initialize a new random number generator that generates
   * random numbers in the range [min, max]
   * @param min - the min value (inclusive)
   * @param max - the max value (inclusive)
   */
  public RandomNumberGenerator(int min, int max) {
    randomIterator = new Random().ints(min, max + 1).iterator();
  }

  /**
   * Returns a random number in the range (min, max)
   * @return a random number in the range (min, max)
   */
  public int nextInt() {
    return randomIterator.nextInt();
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testAscending()
{
  test(IntStream.range(0, INPUT_SIZE),
      MAX_ELEMENTS_COMPARATOR,
      IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).iterator());
  test(IntStream.range(0, INPUT_SIZE),
      MIN_ELEMENTS_COMPARATOR,
      IntStream.range(0, OUTPUT_SIZE).map(x -> OUTPUT_SIZE - 1 - x).iterator());
}

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

return ((IntStream) iterable).iterator();

代码示例来源:origin: prestodb/presto

@Test
public void testShuffled()
{
  List<Integer> list = IntStream.range(0, INPUT_SIZE).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
  Collections.shuffle(list);
  test(list.stream().mapToInt(Integer::intValue),
      MAX_ELEMENTS_COMPARATOR,
      IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).iterator());
  test(list.stream().mapToInt(Integer::intValue),
      MIN_ELEMENTS_COMPARATOR,
      IntStream.range(0, OUTPUT_SIZE).map(x -> OUTPUT_SIZE - 1 - x).iterator());
}

代码示例来源:origin: prestodb/presto

@Test
public void testDescending()
{
  test(IntStream.range(0, INPUT_SIZE).map(x -> INPUT_SIZE - 1 - x),
      MAX_ELEMENTS_COMPARATOR,
      IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).iterator());
  test(IntStream.range(0, INPUT_SIZE).map(x -> INPUT_SIZE - 1 - x),
      MIN_ELEMENTS_COMPARATOR,
      IntStream.range(0, OUTPUT_SIZE).map(x -> OUTPUT_SIZE - 1 - x).iterator());
}

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

@Override
public PrimitiveIterator.OfInt iterator() {
  if (isAllowStreamIteratorAndSpliterator()) {
    return stream().iterator();
  }
  throw newUnsupportedException("iterator");
}

代码示例来源:origin: apache/geode

@Test
public void returnsUniquePorts() {
 // Create a stream that returns the same number more than once, make sure we find
 // a unique port
 PrimitiveIterator.OfInt iterator = IntStream.of(0, 0, 0, 0, 0, 1).iterator();
 UniquePortSupplier supplier = new UniquePortSupplier(iterator::nextInt);
 int port0 = supplier.getAvailablePort();
 int port1 = supplier.getAvailablePort();
 assertThat(port0).isEqualTo(0);
 assertThat(port1).isEqualTo(1);
}

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

final int[] arr = {1, 2, 3};
final PrimitiveIterator.OfInt i1 = Arrays.stream(arr).iterator();
final PrimitiveIterator.OfInt i2 = IntStream.of(arr).iterator();
final Iterator<Integer> i3 = IntStream.of(arr).boxed().iterator();

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

int[] numbers = {1,2,3,4,5,6,7,8,9,10};
 IntStream stream = IntStream.of(numbers);
 Enumerable<Integer> enumerable = new Enumerable(() -> stream.iterator());
 Enumerable<Integer> evens = enumerable.filter((x, i) -> x % 2 == 0 && i != 1);
 return evens.toList().stream();

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

/**
 * Constructor.
 *
 * @param stream wrapped stream
 */
public StreamIntIterator(IntStream stream) {
  this.it = stream.iterator();
}

代码示例来源:origin: zeebe-io/zeebe

public PartitionIdIterator(int startPartitionId, int partitionsCount) {
 iterator =
   IntStream.range(0, partitionsCount)
     .map(index -> (index + startPartitionId) % partitionsCount)
     .iterator();
}

代码示例来源:origin: feixiao/DesignPattern

/**
 * Initialize a new random number generator that generates random numbers in the range [min, max]
 * 
 * @param min the min value (inclusive)
 * @param max the max value (inclusive)
 */
public RandomNumberGenerator(int min, int max) {
 randomIterator = new Random().ints(min, max + 1).iterator();
}

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

package com.company;

import rx.Observable;

import java.util.function.IntPredicate;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {

    final IntPredicate[] p={(x)->true};
    IntStream primesStream=IntStream.iterate(2,n->n+1).filter(i -> p[0].test(i)).peek(i->p[0]=p[0].and(v->v%i!=0)   );

    Observable primes = Observable.from(()->primesStream.iterator());

    primes.take(10).forEach((x) -> System.out.println(x.toString()));

  }

}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Test
public void testAscending()
{
  test(IntStream.range(0, INPUT_SIZE),
      MAX_ELEMENTS_COMPARATOR,
      IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).iterator());
  test(IntStream.range(0, INPUT_SIZE),
      MIN_ELEMENTS_COMPARATOR,
      IntStream.range(0, OUTPUT_SIZE).map(x -> OUTPUT_SIZE - 1 - x).iterator());
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Test
public void testShuffled()
{
  List<Integer> list = IntStream.range(0, INPUT_SIZE).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
  Collections.shuffle(list);
  test(list.stream().mapToInt(Integer::intValue),
      MAX_ELEMENTS_COMPARATOR,
      IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).iterator());
  test(list.stream().mapToInt(Integer::intValue),
      MIN_ELEMENTS_COMPARATOR,
      IntStream.range(0, OUTPUT_SIZE).map(x -> OUTPUT_SIZE - 1 - x).iterator());
}

相关文章