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


Java Spliterators.spliteratorUnknownSize方法代碼示例

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


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

示例1: iterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Iterator<ReaderTxScope> iterator() {
    Spliterator<ReaderTxScope> spliterator = Spliterators.spliteratorUnknownSize(
            scopes.iterator(), Spliterator.SORTED | Spliterator.ORDERED);
    return StreamSupport
            .stream(spliterator, false)
            .filter(tx -> tx.getTransactionId() <= lastDenseRead)
            .distinct()
            .iterator();
}
 
開發者ID:epam,項目名稱:Lagerta,代碼行數:11,代碼來源:ReadTransactions.java

示例2: stream

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Return a stream with the data lines.
 *
 * @return a stream with the data lines
 */
public Stream<String[]> stream() {
	final DataIterator iterator = new DataIterator(getResourcePath());
	final Spliterator<String[]> spliterator = Spliterators
		.spliteratorUnknownSize(iterator, 0);

	return StreamSupport
		.stream(spliterator, false)
		.onClose(iterator::close);
}
 
開發者ID:jenetics,項目名稱:prngine,代碼行數:15,代碼來源:TestData.java

示例3: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<TClass> spliterator() {
	return Spliterators.spliteratorUnknownSize(iterator(), Spliterator.DISTINCT | Spliterator.NONNULL);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:5,代碼來源:ExtendedClassesIterable.java

示例4: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<TInterface> spliterator() {
	return Spliterators.spliteratorUnknownSize(iterator(), Spliterator.DISTINCT | Spliterator.NONNULL);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:5,代碼來源:SuperInterfacesIterable.java

示例5: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
@Override
public Spliterator<T> spliterator() {
    return Spliterators.spliteratorUnknownSize(dataIt, Spliterator.NONNULL);
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:5,代碼來源:DataProvider.java

示例6: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
public Spliterator<String> spliterator() {
    return Spliterators.spliteratorUnknownSize(list.iterator(), 0);
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:4,代碼來源:StreamTest.java

示例7: find

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Return a {@code Stream} that is lazily populated with {@code
 * Path} by searching for files in a file tree rooted at a given starting
 * file.
 *
 * <p> This method walks the file tree in exactly the manner specified by
 * the {@link #walk walk} method. For each file encountered, the given
 * {@link BiPredicate} is invoked with its {@link Path} and {@link
 * BasicFileAttributes}. The {@code Path} object is obtained as if by
 * {@link Path#resolve(Path) resolving} the relative path against {@code
 * start} and is only included in the returned {@link Stream} if
 * the {@code BiPredicate} returns true. Compare to calling {@link
 * java.util.stream.Stream#filter filter} on the {@code Stream}
 * returned by {@code walk} method, this method may be more efficient by
 * avoiding redundant retrieval of the {@code BasicFileAttributes}.
 *
 * <p> The returned stream contains references to one or more open directories.
 * The directories are closed by closing the stream.
 *
 * <p> If an {@link IOException} is thrown when accessing the directory
 * after returned from this method, it is wrapped in an {@link
 * UncheckedIOException} which will be thrown from the method that caused
 * the access to take place.
 *
 * @apiNote
 * This method must be used within a try-with-resources statement or similar
 * control structure to ensure that the stream's open directories are closed
 * promptly after the stream's operations have completed.
 *
 * @param   start
 *          the starting file
 * @param   maxDepth
 *          the maximum number of directory levels to search
 * @param   matcher
 *          the function used to decide whether a file should be included
 *          in the returned stream
 * @param   options
 *          options to configure the traversal
 *
 * @return  the {@link Stream} of {@link Path}
 *
 * @throws  IllegalArgumentException
 *          if the {@code maxDepth} parameter is negative
 * @throws  SecurityException
 *          If the security manager denies access to the starting file.
 *          In the case of the default provider, the {@link
 *          SecurityManager#checkRead(String) checkRead} method is invoked
 *          to check read access to the directory.
 * @throws  IOException
 *          if an I/O error is thrown when accessing the starting file.
 *
 * @see     #walk(Path, int, FileVisitOption...)
 * @since   1.8
 */
public static Stream<Path> find(Path start,
                                int maxDepth,
                                BiPredicate<Path, BasicFileAttributes> matcher,
                                FileVisitOption... options)
    throws IOException
{
    FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
    try {
        Spliterator<FileTreeWalker.Event> spliterator =
            Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
        return StreamSupport.stream(spliterator, false)
                            .onClose(iterator::close)
                            .filter(entry -> matcher.test(entry.file(), entry.attributes()))
                            .map(entry -> entry.file());
    } catch (Error|RuntimeException e) {
        iterator.close();
        throw e;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:74,代碼來源:Files.java

示例8: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Creates a {@link Spliterator} over the elements described by this
 * {@code Iterable}.
 *
 * @implSpec
 * The default implementation creates an
 * <em><a href="Spliterator.html#binding">early-binding</a></em>
 * spliterator from the iterable's {@code Iterator}.  The spliterator
 * inherits the <em>fail-fast</em> properties of the iterable's iterator.
 *
 * @implNote
 * The default implementation should usually be overridden.  The
 * spliterator returned by the default implementation has poor splitting
 * capabilities, is unsized, and does not report any spliterator
 * characteristics. Implementing classes can nearly always provide a
 * better implementation.
 *
 * @return a {@code Spliterator} over the elements described by this
 * {@code Iterable}.
 * @since 1.8
 */
default Spliterator<T> spliterator() {
    return Spliterators.spliteratorUnknownSize(iterator(), 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:Iterable.java

示例9: resources

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * 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,代碼行數:59,代碼來源:ClassLoader.java

示例10: getStream

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Get a {@link Stream} from a generic {@link Iterator}.
 *
 * Depending on the type of terminal operation used on the stream, the
 * iterator may or may not have some elements remaining. Be wary if you
 * re-use the same iterator afterwards.
 *
 * @param iterator
 *            The iterator to wrap
 * @return A stream containing the iterator's elements
 */
public static <T> Stream<T> getStream(Iterator<T> iterator) {
    Spliterator<T> spliterator = Spliterators.spliteratorUnknownSize(iterator, 0);
    return StreamSupport.stream(spliterator, false);
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:16,代碼來源:StreamUtils.java

示例11: spliterator

import java.util.Spliterators; //導入方法依賴的package包/類
/**
 * Creates a {@link Spliterator} over the elements described by this
 * {@code Iterable}.
 *
 * @implSpec
 * The default implementation creates an
 * <em><a href="../util/Spliterator.html#binding">early-binding</a></em>
 * spliterator from the iterable's {@code Iterator}.  The spliterator
 * inherits the <em>fail-fast</em> properties of the iterable's iterator.
 *
 * @implNote
 * The default implementation should usually be overridden.  The
 * spliterator returned by the default implementation has poor splitting
 * capabilities, is unsized, and does not report any spliterator
 * characteristics. Implementing classes can nearly always provide a
 * better implementation.
 *
 * @return a {@code Spliterator} over the elements described by this
 * {@code Iterable}.
 * @since 1.8
 */
default Spliterator<T> spliterator() {
    return Spliterators.spliteratorUnknownSize(iterator(), 0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:Iterable.java


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