@@ -3873,6 +3873,7 @@ public Observable<T> reduce(Func2<T, T, T> accumulator) {
3873
3873
* source Observable as its single item
3874
3874
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
3875
3875
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229470.aspx">MSDN: Observable.Count</a>
3876
+ * @see #longCount()
3876
3877
*/
3877
3878
public Observable <Integer > count () {
3878
3879
return reduce (0 , new Func2 <Integer , T , Integer >() {
@@ -5193,6 +5194,27 @@ public Observable<T> last() {
5193
5194
return create (OperationLast .last (this ));
5194
5195
}
5195
5196
5197
+ /**
5198
+ * Returns an Observable that counts the total number of items in the
5199
+ * source Observable as a 64 bit long.
5200
+ * <p>
5201
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/count.png">
5202
+ *
5203
+ * @return an Observable that emits the number of counted elements of the
5204
+ * source Observable as its single, 64 bit long item
5205
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
5206
+ * @see <a href="http://msdn.microsoft.com/en-us/library/hh229120.aspx">MSDN: Observable.LongCount</a>
5207
+ * @see #count()
5208
+ */
5209
+ public Observable <Long > longCount () {
5210
+ return reduce (0L , new Func2 <Long , T , Long >() {
5211
+ @ Override
5212
+ public Long call (Long t1 , T t2 ) {
5213
+ return t1 + 1 ;
5214
+ }
5215
+ });
5216
+ }
5217
+
5196
5218
/**
5197
5219
* Converts an Observable into a {@link BlockingObservable} (an Observable
5198
5220
* with blocking operators).
0 commit comments