當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。