use of com.oath.cyclops.internal.react.stream.LazyStreamWrapper in project cyclops by aol.
the class OperationsOnFutures method skip.
/**
* <pre>
* {@code assertThat(of(1,2,3,4,5).actOnFutures().skip(2).collect(CyclopsCollectors.toList()).size(),is(3)); }
* </pre>
*
* @param n
* Number of elemenets to skip
* @return Stream with elements skipped
*/
default FutureStream<T> skip(final long n) {
final Continueable sub = this.getSubscription();
sub.registerSkip(n);
final LazyStreamWrapper lastActive = getLastActive();
final LazyStreamWrapper limited = lastActive.withStream(lastActive.stream().skip(n));
return this.withLastActive(limited);
}
use of com.oath.cyclops.internal.react.stream.LazyStreamWrapper in project cyclops by aol.
the class OperationsOnFutures method limit.
/**
* <pre>
* {@code assertThat(of(1,2,3,4,5).actOnFutures().limit(2).collect(CyclopsCollectors.toList()).size(),is(2));}
* </pre>
*
* @param maxSize
* Limit element size to num
* @return Limited Stream
*/
default FutureStream<T> limit(final long maxSize) {
final Continueable sub = this.getSubscription();
sub.registerLimit(maxSize);
final LazyStreamWrapper lastActive = getLastActive();
final LazyStreamWrapper limited = lastActive.withStream(lastActive.stream().limit(maxSize));
return this.withLastActive(limited);
}
Aggregations