use of com.oath.cyclops.react.async.subscription.Continueable in project cyclops by aol.
the class FutureStream method skip.
/*
* FutureStream.of(1,2,3,4).skip(2)
*
* Will result in a stream of (3,4). The first two elements are skipped.
*
* @param n Number of elements to skip
*
* @return FutureStream missing skipped elements
*
* )
*/
@Override
default FutureStream<U> skip(final long n) {
final Continueable sub = this.getSubscription();
sub.registerSkip(n);
return fromStream(ReactiveSeq.oneShotStream(toQueue().stream(sub)).skip(n));
}
use of com.oath.cyclops.react.async.subscription.Continueable in project cyclops by aol.
the class FutureStream method limit.
/*
*
* FutureStream.of(1,2,3,4).limit(2)
*
* Will result in a Stream of (1,2). Only the first two elements are used.
*
* @param maxSize number of elements to take
*
* @return Limited FutureStream
*
*/
@Override
default FutureStream<U> limit(final long maxSize) {
final Continueable sub = this.getSubscription();
sub.registerLimit(maxSize);
return fromStream(ReactiveSeq.oneShotStream(toQueue().stream(sub)).limit(maxSize));
}
use of com.oath.cyclops.react.async.subscription.Continueable 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.react.async.subscription.Continueable 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