the type of array
* @param the type of predicate
* @param the type of consumer
* @param the type of PrimitiveList/List
* @param the type of Optional
* @param the type of Indexed
* @param the type of Iterator
* @param the type of of the stream implementing {@code BaseStream}
* @see Stream
* @see IntStream
* @see LongStream
* @see DoubleStream
*/
public interface BaseStream> extends AutoCloseable {
/**
* Returns a stream consisting of the elements of this stream that match the given predicate.
*
* @param predicate
* @return
*/
@ParallelSupported
S filter(P predicate);
/**
* Keep the elements until the given predicate returns false. The stream should be sorted, which means if x is the first element: predicate.text(x)
returns false, any element y behind x: predicate.text(y)
should returns false.
*
* In parallel Streams, the elements after the first element which predicate
returns false may be tested by predicate too.
*
* @param predicate
* @return
*/
@ParallelSupported
S takeWhile(P predicate);
/**
* Remove the elements until the given predicate returns false. The stream should be sorted, which means if x is the first element: predicate.text(x)
returns true, any element y behind x: predicate.text(y)
should returns true.
*
* In parallel Streams, the elements after the first element which predicate
returns false may be tested by predicate too.
*
* @param predicate
* @return
*/
@ParallelSupported
S dropWhile(P predicate);
/**
* Remove the elements until the given predicate returns false. The stream should be sorted, which means if x is the first element: predicate.text(x)
returns true, any element y behind x: predicate.text(y)
should returns true.
*
* In parallel Streams, the elements after the first element which predicate
returns false may be tested by predicate too.
*
*
* @param predicate
* @param consumer
* @return
*/
@ParallelSupported
S dropWhile(P predicate, C consumer);
@ParallelSupported
S removeIf(P predicate);
@ParallelSupported
S removeIf(P predicate, C consumer);
/**
* Returns Stream of {@code S} with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
*
* @param chunkSize the desired size of each sub sequence (the last may be smaller).
* @return
*/
@SequentialOnly
Stream split(int chunkSize);
/**
* Returns Stream of {@code PL} with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
*
*
* This method only run sequentially, even in parallel stream.
*
* @param chunkSize the desired size of each sub sequence (the last may be smaller).
* @return
*/
@SequentialOnly
public abstract Stream splitToList(int chunkSize);
/**
* Split the stream by the specified predicate.
*
*
* This stream should be sorted by value which is used to verify the border.
*
* This method only run sequentially, even in parallel stream.
*
* @param predicate
* @return
*/
@SequentialOnly
Stream split(final P predicate);
/**
* Split the stream by the specified predicate.
*
* This method only run sequentially, even in parallel stream.
*
* @param predicate
* @return
*/
@SequentialOnly
Stream splitToList(final P predicate);
/**
* Split the stream into two pieces at where
.
* The first piece will be loaded into memory.
*
* @param where
* @return
*/
@SequentialOnly
Stream splitAt(int where);
/**
* Split the stream into two pieces at where
turns to {@code false}
* The first piece will be loaded into memory.
*
*
*
* Stream.of(1, 3, 2, 4, 2, 5).splitBy(i -> i <= 3).forEach(s -> s.println()); // [1, 3, 2], [4, 2, 5]
*
*
*
* @param where
* @return
*/
@SequentialOnly
Stream splitBy(P where);
/**
*
* @param windowSize
* @return
* @see #sliding(int, int)
*/
@SequentialOnly
Stream sliding(int windowSize);
/**
*
* @param windowSize
* @return
* @see #sliding(int, int)
*/
@SequentialOnly
Stream slidingToList(int windowSize);
/**
* Stream.of(1, 2, 3, 4, 5, 6, 7, 8).sliding(3, 1).forEach(Stream::println)
*
output:
* [1, 2, 3]
* [2, 3, 4]
* [3, 4, 5]
* [4, 5, 6]
* [5, 6, 7]
* [6, 7, 8]
*
*
============================================================================
* Stream.of(1, 2, 3, 4, 5, 6, 7, 8).sliding(3, 3).forEach(Stream::println)
*
output:
* [1, 2, 3]
* [4, 5, 6]
* [7, 8]
*
*
============================================================================
* Stream.of(1, 2, 3, 4, 5, 6, 7, 5).sliding(3, 5).forEach(Stream::println)
*
output:
* [1, 2, 3]
* [6, 7, 8]
*
*
* This method only run sequentially, even in parallel stream.
*
* @param windowSize
* @param increment
* @return
*/
@SequentialOnly
Stream sliding(int windowSize, int increment);
/**
*
* @param windowSize
* @param increment
* @return
* @see #sliding(int, int)
*/
@SequentialOnly
Stream slidingToList(int windowSize, int increment);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#intersection(IntList)
*/
@SequentialOnly
S intersection(Collection> c);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#difference(IntList)
*/
@SequentialOnly
S difference(Collection> c);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#symmetricDifference(IntList)
*/
@SequentialOnly
S symmetricDifference(Collection c);
/**
*
* All elements will be loaded to memory and sorted if not yet.
*
* @return
*/
@SequentialOnly
Optional