当前位置: 首页>>代码示例>>Java>>正文


Java Spliterator.SIZED属性代码示例

本文整理汇总了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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:StreamSpliterators.java

示例2: characteristics

@Override
public int characteristics() {
    if (proxyEstimateSize)
        return sp.characteristics();
    else
        return sp.characteristics() & ~(Spliterator.SUBSIZED | Spliterator.SIZED);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:StreamSpliteratorTest.java

示例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());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TestData.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:53,代码来源:Streams.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestData.java

示例6: characteristics

public int characteristics() {
    return Spliterator.NONNULL | Spliterator.SIZED | Spliterator.SUBSIZED;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:3,代码来源:PriorityBlockingQueue.java

示例7: characteristics

@Override
public int characteristics() {
    return Spliterator.SIZED | Spliterator.SUBSIZED |
           Spliterator.ORDERED | Spliterator.IMMUTABLE;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:Streams.java

示例8: characteristics

@Override
public int characteristics() {
    return (s.characteristics() & ~(Spliterator.SIZED | Spliterator.SUBSIZED |
                                    Spliterator.SORTED | Spliterator.ORDERED))
           | Spliterator.DISTINCT;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:StreamSpliterators.java

示例9: characteristics

public int characteristics() {
    return (Spliterator.SIZED | Spliterator.SUBSIZED |
            Spliterator.NONNULL | Spliterator.IMMUTABLE);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:ThreadLocalRandom.java

示例10: characteristics

@Override
public int characteristics() {
    return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
           Spliterator.IMMUTABLE | Spliterator.NONNULL |
           Spliterator.DISTINCT | Spliterator.SORTED;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:Streams.java

示例11: characteristics

@Override
public final int characteristics() {
    return Spliterator.SIZED;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Nodes.java

示例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;
}
 
开发者ID:ozgurdemir,项目名称:item-item-factorization,代码行数:12,代码来源:DatasetInterface.java


注:本文中的java.util.Spliterator.SIZED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。