@@ -3871,6 +3871,7 @@ public Observable<T> reduce(Func2<T, T, T> accumulator) {
3871
3871
* source Observable as its single item
3872
3872
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
3873
3873
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229470.aspx">MSDN: Observable.Count</a>
3874
+ * @see #longCount()
3874
3875
*/
3875
3876
public Observable <Integer > count () {
3876
3877
return reduce (0 , new Func2 <Integer , T , Integer >() {
@@ -5172,6 +5173,27 @@ public Observable<T> last() {
5172
5173
return create (OperationLast .last (this ));
5173
5174
}
5174
5175
5176
+ /**
5177
+ * Returns an Observable that counts the total number of items in the
5178
+ * source Observable as a 64 bit long.
5179
+ * <p>
5180
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/count.png">
5181
+ *
5182
+ * @return an Observable that emits the number of counted elements of the
5183
+ * source Observable as its single, 64 bit long item
5184
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-Operators#count">RxJava Wiki: count()</a>
5185
+ * @see <a href="http://msdn.microsoft.com/en-us/library/hh229120.aspx">MSDN: Observable.LongCount</a>
5186
+ * @see #count()
5187
+ */
5188
+ public Observable <Long > longCount () {
5189
+ return reduce (0L , new Func2 <Long , T , Long >() {
5190
+ @ Override
5191
+ public Long call (Long t1 , T t2 ) {
5192
+ return t1 + 1 ;
5193
+ }
5194
+ });
5195
+ }
5196
+
5175
5197
/**
5176
5198
* Converts an Observable into a {@link BlockingObservable} (an Observable
5177
5199
* with blocking operators).
0 commit comments