Skip to content

Commit

Permalink
Merge pull request #1740 from benjchristensen/countLong
Browse files Browse the repository at this point in the history
longCount -> countLong
  • Loading branch information
benjchristensen committed Oct 10, 2014
2 parents 3e7f71f + fa839bb commit ea13546
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3659,6 +3659,34 @@ public final Integer call(Integer t1, T t2) {
}
});
}

/**
* Returns an Observable that counts the total number of items emitted by the source Observable and emits
* this count as a 64-bit Long.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/longCount.png" alt="">
* <dl>
* <dt><b>Backpressure Support:</b></dt>
* <dd>This operator does not support backpressure because by intent it will receive all values and reduce
* them to a single {@code onNext}.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code longCount} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @return an Observable that emits a single item: the number of items emitted by the source Observable as a
* 64-bit Long item
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Mathematical-and-Aggregate-Operators#count-and-longcount">RxJava wiki: count</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229120.aspx">MSDN: Observable.LongCount</a>
* @see #count()
*/
public final Observable<Long> countLong() {
return reduce(0L, new Func2<Long, T, Long>() {
@Override
public final Long call(Long t1, T t2) {
return t1 + 1;
}
});
}

/**
* Returns an Observable that mirrors the source Observable, except that it drops items emitted by the
Expand Down Expand Up @@ -4992,34 +5020,6 @@ public final Observable<T> limit(int num) {
return take(num);
}

/**
* Returns an Observable that counts the total number of items emitted by the source Observable and emits
* this count as a 64-bit Long.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/longCount.png" alt="">
* <dl>
* <dt><b>Backpressure Support:</b></dt>
* <dd>This operator does not support backpressure because by intent it will receive all values and reduce
* them to a single {@code onNext}.</dd>
* <dt><b>Scheduler:</b></dt>
* <dd>{@code longCount} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @return an Observable that emits a single item: the number of items emitted by the source Observable as a
* 64-bit Long item
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Mathematical-and-Aggregate-Operators#count-and-longcount">RxJava wiki: count</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229120.aspx">MSDN: Observable.LongCount</a>
* @see #count()
*/
public final Observable<Long> longCount() {
return reduce(0L, new Func2<Long, T, Long>() {
@Override
public final Long call(Long t1, T t2) {
return t1 + 1;
}
});
}

/**
* Returns an Observable that applies a specified function to each item emitted by the source Observable and
* emits the results of these function applications.
Expand Down

0 comments on commit ea13546

Please sign in to comment.