From 26a034939464122480d313d287e9ec2979c44613 Mon Sep 17 00:00:00 2001 From: akarnokd Date: Sun, 8 Dec 2013 16:25:26 +0100 Subject: [PATCH] Operation LongCount --- rxjava-core/src/main/java/rx/Observable.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rxjava-core/src/main/java/rx/Observable.java b/rxjava-core/src/main/java/rx/Observable.java index 9482a5f09f..5bc1c7eba2 100644 --- a/rxjava-core/src/main/java/rx/Observable.java +++ b/rxjava-core/src/main/java/rx/Observable.java @@ -3871,6 +3871,7 @@ public Observable reduce(Func2 accumulator) { * source Observable as its single item * @see RxJava Wiki: count() * @see MSDN: Observable.Count + * @see #longCount() */ public Observable count() { return reduce(0, new Func2() { @@ -5172,6 +5173,27 @@ public Observable 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. + *

+ * + * + * @return an Observable that emits the number of counted elements of the + * source Observable as its single, 64 bit long item + * @see RxJava Wiki: count() + * @see MSDN: Observable.LongCount + * @see #count() + */ + public Observable longCount() { + return reduce(0L, new Func2() { + @Override + public Long call(Long t1, T t2) { + return t1 + 1; + } + }); + } + /** * Converts an Observable into a {@link BlockingObservable} (an Observable * with blocking operators).