本文整理汇总了Java中java.util.stream.BaseStream.spliterator方法的典型用法代码示例。如果您正苦于以下问题:Java BaseStream.spliterator方法的具体用法?Java BaseStream.spliterator怎么用?Java BaseStream.spliterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.stream.BaseStream
的用法示例。
在下文中一共展示了BaseStream.spliterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertUnsized
import java.util.stream.BaseStream; //导入方法依赖的package包/类
void assertUnsized(BaseStream<?, ?> s) {
Spliterator<?> sp = s.spliterator();
assertFalse(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED));
assertEquals(sp.estimateSize(), Long.MAX_VALUE);
}
示例2: assertSized
import java.util.stream.BaseStream; //导入方法依赖的package包/类
void assertSized(BaseStream<?, ?> s) {
Spliterator<?> sp = s.spliterator();
assertTrue(sp.hasCharacteristics(Spliterator.SIZED | Spliterator.SUBSIZED));
assertTrue(sp.estimateSize() < Long.MAX_VALUE);
}
示例3: zipWith
import java.util.stream.BaseStream; //导入方法依赖的package包/类
/**
* Creates a new {@link StreamEx} which is the result of applying of the
* mapper {@code BiFunction} to the corresponding elements of this stream
* and the supplied other stream. The resulting stream is ordered if both of
* the input streams are ordered, and parallel if either of the input
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* <p>
* This is a <a href="package-summary.html#StreamOps">quasi-intermediate
* operation</a>.
*
* <p>
* The resulting stream finishes when either of the input streams finish:
* the rest of the longer stream is discarded. It's unspecified whether the
* rest elements of the longer stream are actually consumed.
*
* <p>
* The stream created by this operation may have poor characteristics and
* parallelize badly, so it should be used only when there's no other
* choice. If both input streams are random-access lists or arrays, consider
* using {@link #zip(List, List, BiFunction)} or
* {@link #zip(Object[], Object[], BiFunction)} respectively. If you want to
* zip the stream with the stream of indices, consider using
* {@link EntryStream#of(List)} instead.
*
* @param <V> the type of the other stream elements
* @param <R> the type of the resulting stream elements
* @param other the stream to zip this stream with
* @param mapper a non-interfering, stateless function to apply to the
* corresponding pairs of this stream and other stream elements
* @return the new stream
* @since 0.6.7
* @see #zipWith(BaseStream)
*/
public <V, R> StreamEx<R> zipWith(BaseStream<V, ?> other, BiFunction<? super T, ? super V, ? extends R> mapper) {
return new StreamEx<>(new ZipSpliterator<>(spliterator(), other.spliterator(), mapper, true), context
.combine(other));
}