本文整理汇总了Java中java.util.Spliterator.SIZED属性的典型用法代码示例。如果您正苦于以下问题:Java Spliterator.SIZED属性的具体用法?Java Spliterator.SIZED怎么用?Java Spliterator.SIZED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Spliterator
的用法示例。
在下文中一共展示了Spliterator.SIZED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: characteristics
@Override
public final int characteristics() {
init();
// Get the characteristics from the pipeline
int c = StreamOpFlag.toCharacteristics(StreamOpFlag.toStreamFlags(ph.getStreamAndOpFlags()));
// Mask off the size and uniform characteristics and replace with
// those of the spliterator
// Note that a non-uniform spliterator can change from something
// with an exact size to an estimate for a sub-split, for example
// with HashSet where the size is known at the top level spliterator
// but for sub-splits only an estimate is known
if ((c & Spliterator.SIZED) != 0) {
c &= ~(Spliterator.SIZED | Spliterator.SUBSIZED);
c |= (spliterator.characteristics() & (Spliterator.SIZED | Spliterator.SUBSIZED));
}
return c;
}
示例2: characteristics
@Override
public int characteristics() {
if (proxyEstimateSize)
return sp.characteristics();
else
return sp.characteristics() & ~(Spliterator.SUBSIZED | Spliterator.SIZED);
}
示例3: ofNode
public static OfInt ofNode(String name, Node.OfInt node) {
int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
return new AbstractTestData.IntTestData<>(name, node,
n -> StreamSupport.intStream(n::spliterator, characteristics, false),
n -> StreamSupport.intStream(n::spliterator, characteristics, true),
Node.OfInt::spliterator,
n -> (int) n.count());
}
示例4: zip
/**
* Returns a stream in which each element is the result of passing the corresponding elementY of
* each of {@code streamA} and {@code streamB} to {@code function}.
*
* <p>For example:
*
* <pre>{@code
* Streams.zip(
* Stream.of("foo1", "foo2", "foo3"),
* Stream.of("bar1", "bar2"),
* (arg1, arg2) -> arg1 + ":" + arg2)
* }</pre>
*
* <p>will return {@code Stream.of("foo1:bar1", "foo2:bar2")}.
*
* <p>The resulting stream will only be as long as the shorter of the two input streams; if one
* stream is longer, its extra elements will be ignored.
*
* <p>Note that if you are calling {@link Stream#forEach} on the resulting stream, you might want
* to consider using {@link #forEachPair} instead of this method.
*
* <p><b>Performance note:</b> The resulting stream is not <a
* href="http://gee.cs.oswego.edu/dl/html/StreamParallelGuidance.html">efficiently splittable</a>.
* This may harm parallel performance.
*/
public static <A, B, R> Stream<R> zip(
Stream<A> streamA, Stream<B> streamB, BiFunction<? super A, ? super B, R> function) {
checkNotNull(streamA);
checkNotNull(streamB);
checkNotNull(function);
boolean isParallel = streamA.isParallel() || streamB.isParallel(); // same as Stream.concat
Spliterator<A> splitrA = streamA.spliterator();
Spliterator<B> splitrB = streamB.spliterator();
int characteristics =
splitrA.characteristics()
& splitrB.characteristics()
& (Spliterator.SIZED | Spliterator.ORDERED);
Iterator<A> itrA = Spliterators.iterator(splitrA);
Iterator<B> itrB = Spliterators.iterator(splitrB);
return StreamSupport.stream(
new AbstractSpliterator<R>(
Math.min(splitrA.estimateSize(), splitrB.estimateSize()), characteristics) {
@Override
public boolean tryAdvance(Consumer<? super R> action) {
if (itrA.hasNext() && itrB.hasNext()) {
action.accept(function.apply(itrA.next(), itrB.next()));
return true;
}
return false;
}
},
isParallel);
}
示例5: ofNode
public static OfLong ofNode(String name, Node.OfLong node) {
int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
return new AbstractTestData.LongTestData<>(name, node,
n -> StreamSupport.longStream(n::spliterator, characteristics, false),
n -> StreamSupport.longStream(n::spliterator, characteristics, true),
Node.OfLong::spliterator,
n -> (int) n.count());
}
示例6: characteristics
public int characteristics() {
return Spliterator.NONNULL | Spliterator.SIZED | Spliterator.SUBSIZED;
}
示例7: characteristics
@Override
public int characteristics() {
return Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.ORDERED | Spliterator.IMMUTABLE;
}
示例8: characteristics
@Override
public int characteristics() {
return (s.characteristics() & ~(Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.SORTED | Spliterator.ORDERED))
| Spliterator.DISTINCT;
}
示例9: characteristics
public int characteristics() {
return (Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.NONNULL | Spliterator.IMMUTABLE);
}
示例10: characteristics
@Override
public int characteristics() {
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.IMMUTABLE | Spliterator.NONNULL |
Spliterator.DISTINCT | Spliterator.SORTED;
}
示例11: characteristics
@Override
public final int characteristics() {
return Spliterator.SIZED;
}
示例12: characteristics
/**
* Stream characteristics.
* Distinct: each element is distinct
* Sized: it is known how many elments this list contains
* Nonnull: none of the elements are null
* Immutable: the elements are immutable
* Subsized:
* @return A int of the characteristics.
*/
static int characteristics() {
return Spliterator.DISTINCT | Spliterator.SIZED | Spliterator.NONNULL | Spliterator.IMMUTABLE | Spliterator.SUBSIZED;
}