Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation LongCount #587

Merged
merged 1 commit into from
Dec 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3871,6 +3871,7 @@ public Observable<T> reduce(Func2<T, T, T> accumulator) {
* source Observable as its single item
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229470.aspx">MSDN: Observable.Count</a>
* @see #longCount()
*/
public Observable<Integer> count() {
return reduce(0, new Func2<Integer, T, Integer>() {
Expand Down Expand Up @@ -5172,6 +5173,27 @@ public Observable<T> last() {
return create(OperationLast.last(this));
}

/**
* Returns an Observable that counts the total number of items in the
* source Observable as a 64 bit long.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/count.png">
*
* @return an Observable that emits the number of counted elements of the
* source Observable as its single, 64 bit long item
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229120.aspx">MSDN: Observable.LongCount</a>
* @see #count()
*/
public Observable<Long> longCount() {
return reduce(0L, new Func2<Long, T, Long>() {
@Override
public Long call(Long t1, T t2) {
return t1 + 1;
}
});
}

/**
* Converts an Observable into a {@link BlockingObservable} (an Observable
* with blocking operators).
Expand Down