/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getGeneratedBuilderAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllGeneratedBuilderAnnotations( BaseStream<? extends Excerpt, ?> elements) { return addAllGeneratedBuilderAnnotations(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getValueTypeAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllValueTypeAnnotations(BaseStream<? extends Excerpt, ?> elements) { return addAllValueTypeAnnotations(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * org.inferred.freebuilder.processor.property.Property#getAccessorAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public org.inferred.freebuilder.processor.property.Property.Builder addAllAccessorAnnotations( BaseStream<? extends Excerpt, ?> elements) { return addAllAccessorAnnotations(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getNestedClasses()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllNestedClasses(BaseStream<? extends Excerpt, ?> elements) { return addAllNestedClasses(elements.spliterator()); }
return StreamSupport.stream(new PartitioningSpliterator(in.spliterator(), size), false); new FixedBatchSpliterator<>(new PartitioningSpliterator<>(in.spliterator(), size), batchSize), false);
return stream(new FixedBatchSpliterator<>(in.spliterator(), batchSize), true);
@SuppressWarnings("unchecked") @Override public SPLTR spliterator() { if (stream != null) return (SPLTR) stream.spliterator(); if (spliterator != null) { SPLTR s = spliterator; spliterator = null; return s; } throw new IllegalStateException(CONSUMED_MESSAGE); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getGeneratedBuilderAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllGeneratedBuilderAnnotations( BaseStream<? extends Excerpt, ?> elements) { return addAllGeneratedBuilderAnnotations(elements.spliterator()); }
/** * Adds each element of {@code elements} to the set to be returned from {@link * ExecutorServiceFactory.Key#getTags()}, ignoring duplicate elements (only the first duplicate * element is added). * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public ExecutorServiceFactory.Key.Builder addAllTags(BaseStream<? extends String, ?> elements) { return addAllTags(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * org.inferred.freebuilder.processor.property.Property#getAccessorAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public org.inferred.freebuilder.processor.property.Property.Builder addAllAccessorAnnotations( BaseStream<? extends Excerpt, ?> elements) { return addAllAccessorAnnotations(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getNestedClasses()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllNestedClasses(BaseStream<? extends Excerpt, ?> elements) { return addAllNestedClasses(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * FileStoreKey#getSubPartitions()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public FileStoreKey.Builder addAllSubPartitions(BaseStream<? extends String, ?> elements) { return addAllSubPartitions(elements.spliterator()); }
/** * Adds each element of {@code elements} to the list to be returned from {@link * Datatype#getValueTypeAnnotations()}. * * @return this {@code Builder} object * @throws NullPointerException if {@code elements} is null or contains a null element */ public Datatype.Builder addAllValueTypeAnnotations(BaseStream<? extends Excerpt, ?> elements) { return addAllValueTypeAnnotations(elements.spliterator()); }
/** * Creates a closeable spliterator that when closed will close the underlying stream as well * @param stream The stream to change into a closeable spliterator * @param <R> The type of the stream * @return A spliterator that when closed will also close the underlying stream */ public static <R> CloseableSpliterator<R> spliterator(BaseStream<R, Stream<R>> stream) { Spliterator<R> spliterator = stream.spliterator(); if (spliterator instanceof CloseableSpliterator) { return (CloseableSpliterator<R>) spliterator; } return new StreamToCloseableSpliterator<>(stream, spliterator); }
/** * Wraps a {@link Stream} so that when iterated, a progress bar is shown to track the traversal progress. * For this function the progress bar can be fully customized by using a {@link ProgressBarBuilder}. * @param stream Underlying stream (can be sequential or parallel) * @param pbb An instance of a {@link ProgressBarBuilder} */ public static <T, S extends BaseStream<T, S>> Stream<T> wrap(S stream, ProgressBarBuilder pbb) { Spliterator<T> sp = wrap(stream.spliterator(), pbb); return StreamSupport.stream(sp, stream.isParallel()); }
/** * Wraps a {@link Stream} so that when iterated, a progress bar is shown to track the traversal progress. * For this function the progress bar can be fully customized by using a {@link ProgressBarBuilder}. * @param stream Underlying stream (can be sequential or parallel) * @param pbb An instance of a {@link ProgressBarBuilder} */ public static <T, S extends BaseStream<T, S>> Stream<T> wrap(S stream, ProgressBarBuilder pbb) { Spliterator<T> sp = wrap(stream.spliterator(), pbb); return StreamSupport.stream(sp, stream.isParallel()); }
@Override public <R> ReactiveSeq<R> flatMapStream(Function<? super T, BaseStream<? extends R, ?>> fn) { return this.<R>flux((Flux)flux.flatMap(fn.andThen(s->{ ReactiveSeq<R> res = s instanceof ReactiveSeq ? (ReactiveSeq) s : (ReactiveSeq) ReactiveSeq.fromSpliterator(s.spliterator()); return res; } ))); }
import java.util.Spliterator; import static java.util.Spliterator.ORDERED; import java.util.stream.Stream; /** * @param <T> the type of elements in the stream * @param stream a stream * @return the last element in the stream * @throws AssertionError if the stream is unordered */ public static <T> Optional<T> getLastElement(Stream<T> stream) { Spliterator<T> spliterator = stream.spliterator(); assert (spliterator.hasCharacteristics(ORDERED)): "Operation makes no sense on unordered streams"; // First we skip as many elements as possible while (spliterator.trySplit() != null) { // trySplit() moves the original spliterator forward by the size of the returned spliterator } // Then we consume the last element(s) LastElementConsumer<T> consumer = new LastElementConsumer<>(); spliterator.forEachRemaining(consumer); return consumer.get(); }
return new EntryStream<>(new ZipSpliterator<>(spliterator(), other.spliterator(), SimpleImmutableEntry::new, true), context.combine(other));
return new StreamEx<>(new ZipSpliterator<>(spliterator(), other.spliterator(), mapper, true), context .combine(other));