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

x33g5p2x  于2022-01-16 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(432)

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

Stream.spliterator介绍

暂无

代码示例

代码示例来源:origin: google/guava

@Override
 public Spliterator<T> spliterator() {
  return Streams.stream(iterable).limit(limitSize).spliterator();
 }
};

代码示例来源:origin: google/guava

@Override
public Spliterator<T> spliterator() {
 return Stream.generate(() -> iterable).flatMap(Streams::stream).spliterator();
}

代码示例来源:origin: stanfordnlp/CoreNLP

@Override
 public Spliterator<E> spliterator() {
  if (iterable != null) {
   return iterable.spliterator();
  } else if (stream != null) {
   return stream.spliterator();
  } else {
   return Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED | Spliterator.CONCURRENT);
  }
 }
}

代码示例来源:origin: google/guava

@Override
 public Spliterator<T> spliterator() {
  if (iterable instanceof List) {
   final List<T> list = (List<T>) iterable;
   int toSkip = Math.min(list.size(), numberToSkip);
   return list.subList(toSkip, list.size()).spliterator();
  } else {
   return Streams.stream(iterable).skip(numberToSkip).spliterator();
  }
 }
};

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

@Override
 public Spliterator<T> spliterator() {
  return Streams.stream(iterable).limit(limitSize).spliterator();
 }
};

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

@Override
public Spliterator<T> spliterator() {
 return Stream.generate(() -> iterable).flatMap(Streams::stream).spliterator();
}

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

@Override
 public Spliterator<T> spliterator() {
  if (iterable instanceof List) {
   final List<T> list = (List<T>) iterable;
   int toSkip = Math.min(list.size(), numberToSkip);
   return list.subList(toSkip, list.size()).spliterator();
  } else {
   return Streams.stream(iterable).skip(numberToSkip).spliterator();
  }
 }
};

代码示例来源:origin: uber/NullAway

private boolean isExternalInit(Symbol.ClassSymbol classSymbol) {
 return StreamSupport.stream(NullabilityUtil.getAllAnnotations(classSymbol).spliterator(), false)
   .map((anno) -> anno.getAnnotationType().toString())
   .anyMatch(config::isExternalInitClassAnnotation);
}

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

@Override
 public Spliterator<T> spliterator() {
  if (iterable instanceof List) {
   final List<T> list = (List<T>) iterable;
   int toSkip = Math.min(list.size(), numberToSkip);
   return list.subList(toSkip, list.size()).spliterator();
  } else {
   return Streams.stream(iterable).skip(numberToSkip).spliterator();
  }
 }
};

代码示例来源:origin: google/guava

/**
 * An analogue of {@link java.util.function.DoubleFunction} also accepting an index.
 *
 * <p>This interface is only intended for use by callers of {@link #mapWithIndex(DoubleStream,
 * DoubleFunctionWithIndex)}.
 *
 * @since 21.0
 */
@Beta
public interface DoubleFunctionWithIndex<R> {
 /** Applies this function to the given argument and its index within a stream. */
 R apply(double from, long index);
}

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

/**
 * An analogue of {@link java.util.function.DoubleFunction} also accepting an index.
 *
 * <p>This interface is only intended for use by callers of {@link #mapWithIndex(DoubleStream,
 * DoubleFunctionWithIndex)}.
 *
 * @since 21.0
 */
@Beta
public interface DoubleFunctionWithIndex<R> {
 /** Applies this function to the given argument and its index within a stream. */
 R apply(double from, long index);
}

代码示例来源:origin: google/j2objc

/**
 * An analogue of {@link java.util.function.DoubleFunction} also accepting an index.
 *
 * <p>This interface is only intended for use by callers of {@link #mapWithIndex(DoubleStream,
 * DoubleFunctionWithIndex)}.
 *
 * @since 21.0
 */
@Beta
public interface DoubleFunctionWithIndex<R> {
 /** Applies this function to the given argument and its index within a stream. */
 R apply(double from, long index);
}

代码示例来源:origin: google/guava

for (Stream<? extends T> stream : streams) {
 isParallel |= stream.isParallel();
 Spliterator<? extends T> splitr = stream.spliterator();
 splitrsBuilder.add(splitr);
 characteristics &= splitr.characteristics();

代码示例来源:origin: google/guava

private void testMapWithIndex(Function<Collection<String>, Stream<String>> collectionImpl) {
 SpliteratorTester.of(
     () ->
       Streams.mapWithIndex(
           collectionImpl.apply(ImmutableList.of()), (str, i) -> str + ":" + i)
         .spliterator())
   .expect(ImmutableList.of());
 SpliteratorTester.of(
     () ->
       Streams.mapWithIndex(
           collectionImpl.apply(ImmutableList.of("a", "b", "c", "d", "e")),
           (str, i) -> str + ":" + i)
         .spliterator())
   .expect("a:0", "b:1", "c:2", "d:3", "e:4");
}

代码示例来源:origin: google/guava

public void testConcat_refStream() {
 assertThat(Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d")))
   .containsExactly("a", "b", "c", "d")
   .inOrder();
 SpliteratorTester.of(
     () ->
       Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d"))
         .spliterator())
   .expect("a", "b", "c", "d");
}

代码示例来源:origin: google/guava

public void testMapWithIndex_intStream() {
 SpliteratorTester.of(
     () -> Streams.mapWithIndex(IntStream.of(0, 1, 2), (x, i) -> x + ":" + i).spliterator())
   .expect("0:0", "1:1", "2:2");
}

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

@Test
void iteratorsStreamCharacteristics()
{
  Iterator<Integer> iterator = asList( 1, 2, 3 ).iterator();
  int characteristics = Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.SORTED;
  Stream<Integer> stream = Iterators.stream( iterator, characteristics );
  assertEquals( characteristics, stream.spliterator().characteristics() );
}

代码示例来源:origin: google/guava

public void testMapWithIndex_longStream() {
 SpliteratorTester.of(
     () -> Streams.mapWithIndex(LongStream.of(0, 1, 2), (x, i) -> x + ":" + i).spliterator())
   .expect("0:0", "1:1", "2:2");
}

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

@Test
void iterablesStreamCharacteristics()
{
  Iterable<Integer> iterable = asList( 1, 2, 3 );
  int characteristics = Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.NONNULL;
  Stream<Integer> stream = Iterables.stream( iterable, characteristics );
  assertEquals( characteristics, stream.spliterator().characteristics() );
}

代码示例来源:origin: google/guava

@GwtIncompatible // TODO(b/38490623): reenable after GWT double-to-string conversion is fixed
public void testMapWithIndex_doubleStream() {
 SpliteratorTester.of(
     () ->
       Streams.mapWithIndex(DoubleStream.of(0, 1, 2), (x, i) -> x + ":" + i).spliterator())
   .expect("0.0:0", "1.0:1", "2.0:2");
}

相关文章