ArrayList<String> arrayList = new MySequentialArrayList(); System.out.println(arrayList.parallelStream().isParallel());
static StreamContext of(BaseStream<?, ?> stream) { if (stream instanceof BaseStreamEx) return ((BaseStreamEx<?, ?, ?, ?>) stream).context; if (mustCloseStream(stream)) return new StreamContext(stream.isParallel()).onClose(stream::close); return stream.isParallel() ? PARALLEL : SEQUENTIAL; } }
/** * 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()); }
StreamContext combine(BaseStream<?, ?> other) { if (other == null) return this; StreamContext otherStrategy = of(other); StreamContext result = this; if (other.isParallel() && !parallel) result = parallel(); if (otherStrategy.closeHandler != null) result = result.onClose(otherStrategy.closeHandler); return result; }