當前位置: 首頁>>代碼示例>>Java>>正文


Java Spliterator.NONNULL屬性代碼示例

本文整理匯總了Java中java.util.Spliterator.NONNULL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Spliterator.NONNULL屬性的具體用法?Java Spliterator.NONNULL怎麽用?Java Spliterator.NONNULL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.Spliterator的用法示例。


在下文中一共展示了Spliterator.NONNULL屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: concat

/**
 * Returns a {@link Stream} containing the elements of the first stream, followed by the elements
 * of the second stream, and so on.
 *
 * <p>This is equivalent to {@code Stream.of(streams).flatMap(stream -> stream)}, but the returned
 * stream may perform better.
 *
 * @see Stream#concat(Stream, Stream)
 */
@SafeVarargs
public static <T> Stream<T> concat(Stream<? extends T>... streams) {
  // TODO(lowasser): consider an implementation that can support SUBSIZED
  boolean isParallel = false;
  int characteristics = Spliterator.ORDERED | Spliterator.SIZED | Spliterator.NONNULL;
  long estimatedSize = 0L;
  ImmutableList.Builder<Spliterator<? extends T>> splitrsBuilder =
      new ImmutableList.Builder<>(streams.length);
  for (Stream<? extends T> stream : streams) {
    isParallel |= stream.isParallel();
    Spliterator<? extends T> splitr = stream.spliterator();
    splitrsBuilder.add(splitr);
    characteristics &= splitr.characteristics();
    estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize());
  }
  return StreamSupport.stream(
      CollectSpliterators.flatMap(
          splitrsBuilder.build().spliterator(),
          splitr -> (Spliterator<T>) splitr,
          characteristics,
          estimatedSize),
      isParallel);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:32,代碼來源:Streams.java

示例2: characteristics

public int characteristics() {
    return Spliterator.DISTINCT | Spliterator.CONCURRENT |
        Spliterator.NONNULL;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:4,代碼來源:ConcurrentHashMap.java

示例3: characteristics

public int characteristics() {
    return Spliterator.CONCURRENT | Spliterator.NONNULL;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:3,代碼來源:ConcurrentHashMap.java

示例4: characteristics

public int characteristics() {
    return (Spliterator.ORDERED |
            Spliterator.NONNULL |
            Spliterator.CONCURRENT);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:LinkedTransferQueue.java

示例5: characteristics

public int characteristics() {
    return Spliterator.DISTINCT | Spliterator.SORTED |
        Spliterator.ORDERED | Spliterator.CONCURRENT |
        Spliterator.NONNULL;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:ConcurrentSkipListMap.java

示例6: 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

示例7: characteristics

public int characteristics() {
    return (Spliterator.SIZED | Spliterator.SUBSIZED |
            Spliterator.NONNULL | Spliterator.IMMUTABLE);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:ThreadLocalRandom.java

示例8: characteristics

public int characteristics() {
    return Spliterator.ORDERED | Spliterator.NONNULL |
        Spliterator.CONCURRENT;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:LinkedBlockingQueue.java

示例9: resources

/**
 * Returns a stream whose elements are the URLs of all the resources with
 * the given name. A resource is some data (images, audio, text, etc) that
 * can be accessed by class code in a way that is independent of the
 * location of the code.
 *
 * <p> The name of a resource is a {@code /}-separated path name that
 * identifies the resource.
 *
 * <p> The resources will be located when the returned stream is evaluated.
 * If the evaluation results in an {@code IOException} then the I/O
 * exception is wrapped in an {@link UncheckedIOException} that is then
 * thrown.
 *
 * <p> Resources in named modules are subject to the encapsulation rules
 * specified by {@link Module#getResourceAsStream Module.getResourceAsStream}.
 * Additionally, and except for the special case where the resource has a
 * name ending with "{@code .class}", this method will only find resources in
 * packages of named modules when the package is {@link Module#isOpen(String)
 * opened} unconditionally (even if the caller of this method is in the
 * same module as the resource). </p>
 *
 * @implSpec The default implementation invokes {@link #getResources(String)
 * getResources} to find all the resources with the given name and returns
 * a stream with the elements in the enumeration as the source.
 *
 * @apiNote When overriding this method it is recommended that an
 * implementation ensures that any delegation is consistent with the {@link
 * #getResource(java.lang.String) getResource(String)} method. This should
 * ensure that the first element returned by the stream is the same
 * resource that the {@code getResource(String)} method would return.
 *
 * @param  name
 *         The resource name
 *
 * @return  A stream of resource {@link java.net.URL URL} objects. If no
 *          resources could  be found, the stream will be empty. Resources
 *          for which a {@code URL} cannot be constructed, are in a package
 *          that is not opened unconditionally, or access to the resource
 *          is denied by the security manager, will not be in the stream.
 *
 * @throws  NullPointerException If {@code name} is {@code null}
 *
 * @since  9
 */
public Stream<URL> resources(String name) {
    Objects.requireNonNull(name);
    int characteristics = Spliterator.NONNULL | Spliterator.IMMUTABLE;
    Supplier<Spliterator<URL>> si = () -> {
        try {
            return Spliterators.spliteratorUnknownSize(
                getResources(name).asIterator(), characteristics);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    };
    return StreamSupport.stream(si, characteristics, false);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:58,代碼來源:ClassLoader.java


注:本文中的java.util.Spliterator.NONNULL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。