> extends AutoCloseable {
/**
* Returns a stream consisting of the elements of this stream that match
* the given predicate.
*
* This is an intermediate
* operation.
*
* @param predicate a non-interfering,
* stateless
* predicate to apply to each element to determine if it
* should be included
* @return the new stream
*/
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
*/
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
*/
S dropWhile(P predicate);
/**
* Returns a stream consisting of the remaining elements of this stream
* after removing and consuming the first {@code n} elements of the stream.
* If this stream contains fewer than {@code n} elements then an
* empty stream will be returned.
*
* @param n
* @param consumer
* @return
*/
S remove(long n, C consumer);
S removeIf(P predicate);
S removeIf(P predicate, C consumer);
/**
* Returns a stream consisting of the remaining elements of this stream
* after removing and consuming until the specified predicate
return false.
* If there is no more elements then an empty stream will be returned.
*
* @param predicate
* @param consumer
* @return
*/
S removeWhile(P predicate, C consumer);
/**
* Returns Stream of ByteStream with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
*
* @param size
* @return
*/
Stream split(int size);
/**
* Returns Stream of Stream 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 size
* @return
*/
public abstract Stream splitToList(int size);
/**
* 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
*/
Stream split(final P predicate);
/**
* 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
*/
Stream splitToList(final P predicate);
/**
* Split the stream by the specified predicate.
*
*
*
* // split the number sequence by window 5.
* Stream.of(1, 2, 3, 5, 7, 9, 10, 11, 19).splitToList(MutableInt.of(5), (e, b) -> e <= b.intValue(), b -> b.addAndGet(5)).forEach(N::println);
*
*
*
* This stream should be sorted by value which is used to verify the border.
*
* This method only run sequentially, even in parallel stream.
*
* @param identity
* @param predicate
* @param identityUpdate
* @return
*/
Stream split(final U identity, final BiFunction super T, ? super U, Boolean> predicate, final Consumer super U> identityUpdate);
/**
* Split the stream by the specified predicate.
*
*
*
* // split the number sequence by window 5.
* Stream.of(1, 2, 3, 5, 7, 9, 10, 11, 19).splitToList(MutableInt.of(5), (e, b) -> e <= b.intValue(), b -> b.addAndGet(5)).forEach(N::println);
*
*
*
* This stream should be sorted by value which is used to verify the border.
*
* This method only run sequentially, even in parallel stream.
*
* @param identity
* @param predicate
* @param identityUpdate
* @return
*/
Stream splitToList(final U identity, final BiFunction super T, ? super U, Boolean> predicate, final Consumer super U> identityUpdate);
/**
* Split the stream into two pieces at where
*
* @param where
* @return
*/
Stream splitAt(int where);
/**
* Split the stream into two pieces at where
*
* @param where
* @return
*/
Stream splitBy(P where);
/**
*
* @param windowSize
* @return
* @see #sliding(int, int)
*/
Stream sliding(int windowSize);
/**
*
* @param windowSize
* @return
* @see #sliding(int, int)
*/
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
*/
Stream sliding(int windowSize, int increment);
/**
*
* @param windowSize
* @param increment
* @return
* @see #sliding(int, int)
*/
Stream slidingToList(int windowSize, int increment);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#intersection(IntList)
*/
S intersection(Collection> c);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#difference(IntList)
*/
S difference(Collection> c);
/**
*
* This method only run sequentially, even in parallel stream.
*
* @param c
* @return
* @see IntList#symmetricDifference(IntList)
*/
S symmetricDifference(Collection c);
/**
*
* All elements will be loaded to memory and sorted if not yet.
*
* @return
*/
Optional