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


Java StreamSupport.stream方法代码示例

本文整理汇总了Java中java.util.stream.StreamSupport.stream方法的典型用法代码示例。如果您正苦于以下问题:Java StreamSupport.stream方法的具体用法?Java StreamSupport.stream怎么用?Java StreamSupport.stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.stream.StreamSupport的用法示例。


在下文中一共展示了StreamSupport.stream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intersperse

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
public static <T> Stream<T> intersperse(Stream<T> s, T e) {
    final Iterator<T> inner = s.iterator();
    final AtomicBoolean returnE = new AtomicBoolean(false);

    final Iterator<T> it = new Iterator<T>() {
        @Override
        public boolean hasNext() {
            return inner.hasNext();
        }

        @Override
        public T next() {
            final T ret = returnE.get() ? e : inner.next();
            returnE.set(!returnE.get());
            return ret;
        }
    };

    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED),
            false);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:23,代码来源:Helpers.java

示例2: toStream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
private static <T> Stream<T> toStream(final Iterable<T> iterable) {
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(
                    iterable.iterator(),
                    Spliterator.ORDERED
            ),
            false
    );
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:10,代码来源:ServiceUserImplRepository.java

示例3: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
@Override
public Stream<JarEntry> stream() {
    return StreamSupport.stream(Spliterators.spliterator(
            new JarEntryIterator(), size(),
            Spliterator.ORDERED | Spliterator.DISTINCT |
                    Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:JarFile.java

示例4: of

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
public static <T> Stream<T> of(Iterator<T> iterator) {
    return StreamSupport.stream(Spliterators.spliterator(iterator, 0, Spliterator.ORDERED), false);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:Streams.java

示例5: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
public Stream<T> stream() {
	return StreamSupport.stream(this.spliterator(), false);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:4,代码来源:AbstractQuery.java

示例6: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/** TODO: Implement {@link Collection} interface so this is an override */
public Stream<KdbDict> stream() {
	Iterable<KdbDict> iterable = () -> iterator();
	return StreamSupport.stream(iterable.spliterator(), false);
}
 
开发者ID:BuaBook,项目名称:java-kdb-communication,代码行数:6,代码来源:KdbTable.java

示例7: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
static Stream<DoubleMultiPoint> stream(List<DoubleTimeSeries> timeSeriesList) {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
            iterator(timeSeriesList),
            Spliterator.ORDERED | Spliterator.IMMUTABLE), false);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:6,代码来源:DoubleTimeSeries.java

示例8: getContent

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
@Override
public final Stream<String> getContent(String path) {
    Spliterator<String> iter = new IteratorFromReader(getStream.apply(path));
    return StreamSupport.stream(iter, false);
}
 
开发者ID:isel-leic-mpd,项目名称:mpd-2017-i41d,代码行数:6,代码来源:Request.java

示例9: deleteAll

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
@Override
public long deleteAll() {
    final Iterator<ViewRow> grantingTicketsIt = getViewResultIteratorForPrefixedTickets(TicketGrantingTicket.PREFIX + '-').iterator();
    final Iterator<ViewRow> serviceTicketsIt = getViewResultIteratorForPrefixedTickets(ServiceTicket.PREFIX + '-').iterator();
    final Iterator<ViewRow> proxyTicketsIt = getViewResultIteratorForPrefixedTickets(ProxyTicket.PREFIX + '-').iterator();
    final Iterator<ViewRow> proxyGrantingTicketsIt = getViewResultIteratorForPrefixedTickets(ProxyGrantingTicket.PREFIX + '-').iterator();
    final Iterator<ViewRow> accessTokenIt = getViewResultIteratorForPrefixedTickets(AccessToken.PREFIX + '-').iterator();
    final Iterator<ViewRow> oauthcodeIt = getViewResultIteratorForPrefixedTickets(OAuthCode.PREFIX + '-').iterator();
    final Iterator<ViewRow> refreshTokenIt = getViewResultIteratorForPrefixedTickets(RefreshToken.PREFIX + '-').iterator();

    final int count = getViewRowCountFromViewResultIterator(grantingTicketsIt)
            + getViewRowCountFromViewResultIterator(serviceTicketsIt)
            + getViewRowCountFromViewResultIterator(proxyTicketsIt)
            + getViewRowCountFromViewResultIterator(proxyGrantingTicketsIt)
            + getViewRowCountFromViewResultIterator(accessTokenIt)
            + getViewRowCountFromViewResultIterator(oauthcodeIt)
            + getViewRowCountFromViewResultIterator(refreshTokenIt);

    Stream<ViewRow> tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(grantingTicketsIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(serviceTicketsIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(proxyTicketsIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(proxyGrantingTicketsIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(accessTokenIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(oauthcodeIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));

    tickets = StreamSupport.stream(Spliterators.spliteratorUnknownSize(refreshTokenIt, Spliterator.ORDERED), true);
    tickets.forEach(t -> this.couchbase.bucket().remove(t.document()));
    
    return count;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:42,代码来源:CouchbaseTicketRegistry.java

示例10: recordStream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
private static <K, V> Stream<ConsumerRecord<K, V>> recordStream(ConsumerRecords<K, V> records) {
    return StreamSupport.stream(records.spliterator(), false);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:4,代码来源:LeadStateLoader.java

示例11: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/**
 * Return an ordered {@code Stream} over the ZIP file entries.
 * Entries appear in the {@code Stream} in the order they appear in
 * the central directory of the ZIP file.
 *
 * @return an ordered {@code Stream} of entries in this ZIP file
 * @throws IllegalStateException if the zip file has been closed
 * @since 1.8
 */
public Stream<? extends ZipEntry> stream() {
    return StreamSupport.stream(Spliterators.spliterator(
            new ZipEntryIterator(), size(),
            Spliterator.ORDERED | Spliterator.DISTINCT |
                    Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:ZipFile.java

示例12: findAll

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/**
 * Returns a stream of match results from this scanner. The stream
 * contains the same results in the same order that would be returned by
 * calling {@code findWithinHorizon(pattern, 0)} and then {@link #match}
 * successively as long as {@link #findWithinHorizon findWithinHorizon()}
 * finds matches.
 *
 * <p>The resulting stream is sequential and ordered. All stream elements are
 * non-null.
 *
 * <p>Scanning starts upon initiation of the terminal stream operation, using the
 * current state of this scanner. Subsequent calls to any methods on this scanner
 * other than {@link #close} and {@link #ioException} may return undefined results
 * or may cause undefined effects on the returned stream. The returned stream's source
 * {@code Spliterator} is <em>fail-fast</em> and will, on a best-effort basis, throw a
 * {@link java.util.ConcurrentModificationException} if any such calls are detected
 * during stream pipeline execution.
 *
 * <p>After stream pipeline execution completes, this scanner is left in an indeterminate
 * state and cannot be reused.
 *
 * <p>If this scanner contains a resource that must be released, this scanner
 * should be closed, either by calling its {@link #close} method, or by
 * closing the returned stream. Closing the stream will close the underlying scanner.
 * {@code IllegalStateException} is thrown if the scanner has been closed when this
 * method is called, or if this scanner is closed during stream pipeline execution.
 *
 * <p>As with the {@link #findWithinHorizon findWithinHorizon()} methods, this method
 * might block waiting for additional input, and it might buffer an unbounded amount of
 * input searching for a match.
 *
 * @apiNote
 * For example, the following code will read a file and return a list
 * of all sequences of characters consisting of seven or more Latin capital
 * letters:
 *
 * <pre>{@code
 * try (Scanner sc = new Scanner(Paths.get("input.txt"))) {
 *     Pattern pat = Pattern.compile("[A-Z]{7,}");
 *     List<String> capWords = sc.findAll(pat)
 *                               .map(MatchResult::group)
 *                               .collect(Collectors.toList());
 * }
 * }</pre>
 *
 * @param pattern the pattern to be matched
 * @return a sequential stream of match results
 * @throws NullPointerException if pattern is null
 * @throws IllegalStateException if this scanner is closed
 * @since 9
 */
public Stream<MatchResult> findAll(Pattern pattern) {
    Objects.requireNonNull(pattern);
    ensureOpen();
    Stream<MatchResult> stream = StreamSupport.stream(new FindSpliterator(pattern), false);
    return stream.onClose(this::close);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:58,代码来源:Scanner.java

示例13: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/**
 * Returns a sequential {@code Stream} with this collection as its source.
 *
 * <p>This method should be overridden when the {@link #spliterator()}
 * method cannot return a spliterator that is {@code IMMUTABLE},
 * {@code CONCURRENT}, or <em>late-binding</em>. (See {@link #spliterator()}
 * for details.)
 *
 * @implSpec
 * The default implementation creates a sequential {@code Stream} from the
 * collection's {@code Spliterator}.
 *
 * @return a sequential {@code Stream} over the elements in this collection
 * @since 1.8
 */
default Stream<E> stream() {
    return StreamSupport.stream(spliterator(), false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:Collection.java

示例14: parallelStream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/**
 * Returns a possibly parallel {@code Stream} with this collection as its
 * source.  It is allowable for this method to return a sequential stream.
 *
 * <p>This method should be overridden when the {@link #spliterator()}
 * method cannot return a spliterator that is {@code IMMUTABLE},
 * {@code CONCURRENT}, or <em>late-binding</em>. (See {@link #spliterator()}
 * for details.)
 *
 * @implSpec
 * The default implementation creates a parallel {@code Stream} from the
 * collection's {@code Spliterator}.
 *
 * @return a possibly parallel {@code Stream} over the elements in this
 * collection
 * @since 1.8
 */
default Stream<E> parallelStream() {
    return StreamSupport.stream(spliterator(), true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Collection.java

示例15: stream

import java.util.stream.StreamSupport; //导入方法依赖的package包/类
/**
 * Returns a sequential {@link Stream} with the specified range of the
 * specified array as its source.
 *
 * @param <T> the type of the array elements
 * @param array the array, assumed to be unmodified during use
 * @param startInclusive the first index to cover, inclusive
 * @param endExclusive index immediately past the last index to cover
 * @return a {@code Stream} for the array range
 * @throws ArrayIndexOutOfBoundsException if {@code startInclusive} is
 *         negative, {@code endExclusive} is less than
 *         {@code startInclusive}, or {@code endExclusive} is greater than
 *         the array size
 * @since 1.8
 */
public static <T> Stream<T> stream(T[] array, int startInclusive, int endExclusive) {
    return StreamSupport.stream(spliterator(array, startInclusive, endExclusive), false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Arrays.java


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