Java Code Examples for java.util.Spliterators#emptySpliterator()

The following examples show how to use java.util.Spliterators#emptySpliterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagingSpliterator.java    From robozonky with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch data immediately before traversing or sub-page splitting.
 */
private Spliterator<T> ensurePage() {
    if (danglingFirstPage != null) {
        final Spliterator<T> fp = danglingFirstPage;
        danglingFirstPage = null;
        currentPage = fp;
        start = fp.getExactSizeIfKnown();
        return fp;
    } else if (currentPage != null) {
        return currentPage;
    } else if (start >= end) {
        return Spliterators.emptySpliterator();
    }
    var spliterator = spliterator(supplier.fetch(start, min(end - start, pageSize), l -> end = min(l, end)));
    start += spliterator.getExactSizeIfKnown();
    currentPage = spliterator;
    return spliterator;
}
 
Example 2
Source File: HeadTailSpliterator.java    From streamex with Apache License 2.0 6 votes vote down vote up
private boolean init() {
    if (context == null)
        return false;
    if (target == null) {
        Box<T> first = new Box<>();
        source = TailSpliterator.tryAdvanceWithTail(source, first);
        Stream<U> stream = source == null ? emptyMapper.get() : mapper.apply(first.a, StreamEx.of(source));
        source = null;
        mapper = null;
        emptyMapper = null;
        if (stream == null) {
            target = Spliterators.emptySpliterator();
        } else {
            StreamContext ctx = StreamContext.of(stream);
            if (ctx.closeHandler != null)
                context.onClose(ctx.closeHandler);
            target = stream.spliterator();
        }
    }
    return true;
}
 
Example 3
Source File: SkipLastSpliterator.java    From cyclops with Apache License 2.0 5 votes vote down vote up
public static <T> Spliterator<T> dropRight(Spliterator<T> source, int skip){

        if(skip==0){
            return source;
        }
        if(skip==source.getExactSizeIfKnown()){ //right sized already
            return Spliterators.emptySpliterator();
        }

        return new SkipLastSpliterator<T>(source,skip);
    }
 
Example 4
Source File: TestHelpers.java    From streamex with Apache License 2.0 5 votes vote down vote up
@Override
public Spliterator<T> trySplit() {
    Spliterator<T> source = this.source;
    switch (ThreadLocalRandom.current().nextInt(3)) {
    case 0:
        return Spliterators.emptySpliterator();
    case 1:
        this.source = Spliterators.emptySpliterator();
        return source;
    default:
        Spliterator<T> split = source.trySplit();
        return split == null ? null : new EmptyingSpliterator<>(split);
    }
}
 
Example 5
Source File: Empty.java    From jenetics with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<Object> spliterator() {
	return Spliterators.emptySpliterator();
}
 
Example 6
Source File: Nodes.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 7
Source File: Empty.java    From jenetics with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<Object> spliterator() {
	return Spliterators.emptySpliterator();
}
 
Example 8
Source File: Nodes.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 9
Source File: EmptyDeque.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 10
Source File: Nodes.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 11
Source File: Nodes.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 12
Source File: Nodes.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 13
Source File: Nodes.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Spliterator<T> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 14
Source File: AbstractStreamEx.java    From streamex with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a {@code StreamEx} consisting of the distinct elements (according
 * to {@link Object#equals(Object)}) which appear at least specified number
 * of times in this stream.
 *
 * <p>
 * This operation is not guaranteed to be stable: any of equal elements can
 * be selected for the output. However if this stream is ordered then order
 * is preserved.
 *
 * <p>
 * This is a stateful <a
 * href="package-summary.html#StreamOps">quasi-intermediate</a> operation.
 *
 * @param atLeast minimal number of occurrences required to select the
 *        element. If atLeast is 1 or less, then this method is equivalent
 *        to {@link #distinct()}.
 * @return the new stream
 * @see #distinct()
 * @since 0.3.1
 */
public S distinct(long atLeast) {
    if (atLeast <= 1)
        return distinct();
    Spliterator<T> spliterator = spliterator();
    Spliterator<T> result;
    if (spliterator.hasCharacteristics(Spliterator.DISTINCT))
        // already distinct: cannot have any repeating elements
        result = Spliterators.emptySpliterator();
    else
        result = new DistinctSpliterator<>(spliterator, atLeast);
    return supply(result);
}
 
Example 15
Source File: SynchronousQueue.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an empty spliterator in which calls to
 * {@link java.util.Spliterator#trySplit()} always return {@code null}.
 *
 * @return an empty spliterator
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 16
Source File: SynchronousQueue.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an empty spliterator in which calls to
 * {@link java.util.Spliterator#trySplit()} always return {@code null}.
 *
 * @return an empty spliterator
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 17
Source File: SynchronousQueue.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an empty spliterator in which calls to
 * {@link java.util.Spliterator#trySplit()} always return {@code null}.
 *
 * @return an empty spliterator
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 18
Source File: StreamEx.java    From streamex with Apache License 2.0 2 votes vote down vote up
/**
 * Performs a cross product of current stream with specified
 * {@link Collection} of elements. As a result the {@link EntryStream} is
 * created whose keys are elements of current stream and values are elements
 * of the specified collection.
 * 
 * <p>
 * The resulting stream contains all the possible combinations of keys and
 * values.
 * 
 * <p>
 * This is an <a href="package-summary.html#StreamOps">intermediate</a>
 * operation.
 * 
 * @param <V> the type of collection elements
 * @param other the collection to perform a cross product with
 * @return the new {@code EntryStream}
 * @throws NullPointerException if other is null
 * @since 0.2.3
 */
public <V> EntryStream<T, V> cross(Collection<? extends V> other) {
    if (other.isEmpty())
        return new EntryStream<>(Spliterators.emptySpliterator(), context);
    return cross(t -> of(other));
}
 
Example 19
Source File: SynchronousQueue.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns an empty spliterator in which calls to
 * {@link java.util.Spliterator#trySplit()} always return {@code null}.
 *
 * @return an empty spliterator
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}
 
Example 20
Source File: SynchronousQueue.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an empty spliterator in which calls to
 * {@link java.util.Spliterator#trySplit()} always return {@code null}.
 *
 * @return an empty spliterator
 * @since 1.8
 */
public Spliterator<E> spliterator() {
    return Spliterators.emptySpliterator();
}