@@ -1696,30 +1696,9 @@ public static <T> Observable<T> reduce(Observable<T> sequence, Func2<T, T, T> ac
1696
1696
}
1697
1697
1698
1698
/**
1699
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
1700
- * source Observable, then feeds the result of that function along with the second item emitted
1701
- * by an Observable into the same function, and so on until all items have been emitted by the
1702
- * source Observable, emitting the final result from the final call to your function as its sole
1703
- * output.
1704
- * <p>
1705
- * This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an <code>inject</code>
1706
- * method that does a similar operation on lists.
1707
- * <p>
1708
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/reduce.png">
1699
+ * Used by dynamic languages.
1709
1700
*
1710
- * @param <T>
1711
- * the type item emitted by the source Observable
1712
- * @param sequence
1713
- * the source Observable
1714
- * @param accumulator
1715
- * an accumulator function to be invoked on each element from the sequence, whose
1716
- * result will be used in the next accumulator call (if applicable)
1717
- *
1718
- * @return an Observable that emits a single element that is the result of accumulating the
1719
- * output from applying the accumulator to the sequence of items emitted by the source
1720
- * Observable
1721
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
1722
- * @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1701
+ * @see #reduce(Observable, Func2)
1723
1702
*/
1724
1703
public static <T > Observable <T > reduce (final Observable <T > sequence , final Object accumulator ) {
1725
1704
@ SuppressWarnings ("rawtypes" )
@@ -1735,6 +1714,22 @@ public T call(T t1, T t2) {
1735
1714
});
1736
1715
}
1737
1716
1717
+ /**
1718
+ * @see #reduce(Observable, Func2)
1719
+ */
1720
+ public static <T > Observable <T > aggregate (Observable <T > sequence , Func2 <T , T , T > accumulator ) {
1721
+ return reduce (sequence , accumulator );
1722
+ }
1723
+
1724
+ /**
1725
+ * Used by dynamic languages.
1726
+ *
1727
+ * @see #reduce(Observable, Func2)
1728
+ */
1729
+ public static <T > Observable <T > aggregate (Observable <T > sequence , Object accumulator ) {
1730
+ return reduce (sequence , accumulator );
1731
+ }
1732
+
1738
1733
/**
1739
1734
* Returns an Observable that applies a function of your choosing to the first item emitted by a
1740
1735
* source Observable, then feeds the result of that function along with the second item emitted
@@ -1770,33 +1765,9 @@ public static <T, R> Observable<R> reduce(Observable<T> sequence, R initialValue
1770
1765
}
1771
1766
1772
1767
/**
1773
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
1774
- * source Observable, then feeds the result of that function along with the second item emitted
1775
- * by an Observable into the same function, and so on until all items have been emitted by the
1776
- * source Observable, emitting the final result from the final call to your function as its sole
1777
- * output.
1778
- * <p>
1779
- * This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an <code>inject</code>
1780
- * method that does a similar operation on lists.
1781
- * <p>
1782
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/reduce.png">
1768
+ * Used by dynamic languages.
1783
1769
*
1784
- * @param <T>
1785
- * the type item emitted by the source Observable
1786
- * @param <R>
1787
- * the type returned for each item of the target observable
1788
- * @param sequence
1789
- * the source Observable
1790
- * @param initialValue
1791
- * a seed passed into the first execution of the accumulator function
1792
- * @param accumulator
1793
- * an accumulator function to be invoked on each element from the sequence, whose
1794
- * result will be used in the next accumulator call (if applicable)
1795
- * @return an Observable that emits a single element that is the result of accumulating the
1796
- * output from applying the accumulator to the sequence of items emitted by the source
1797
- * Observable
1798
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
1799
- * @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1770
+ * @see #reduce(Observable, Object, Func2)
1800
1771
*/
1801
1772
public static <T , R > Observable <R > reduce (final Observable <T > sequence , final R initialValue , final Object accumulator ) {
1802
1773
@ SuppressWarnings ("rawtypes" )
@@ -1810,6 +1781,22 @@ public R call(R r, T t) {
1810
1781
});
1811
1782
}
1812
1783
1784
+ /**
1785
+ * @see #reduce(Observable, Object, Func2)
1786
+ */
1787
+ public static <T , R > Observable <R > aggregate (Observable <T > sequence , R initialValue , Func2 <R , T , R > accumulator ) {
1788
+ return reduce (sequence , initialValue , accumulator );
1789
+ }
1790
+
1791
+ /**
1792
+ * Used by dynamic languages.
1793
+ *
1794
+ * @see #reduce(Observable, Object, Func2)
1795
+ */
1796
+ public static <T , R > Observable <R > aggregate (Observable <T > sequence , R initialValue , Object accumulator ) {
1797
+ return reduce (sequence , initialValue , accumulator );
1798
+ }
1799
+
1813
1800
/**
1814
1801
* Returns an Observable that applies a function of your choosing to the first item emitted by a
1815
1802
* source Observable, then feeds the result of that function along with the second item emitted
@@ -1834,23 +1821,9 @@ public static <T> Observable<T> scan(Observable<T> sequence, Func2<T, T, T> accu
1834
1821
}
1835
1822
1836
1823
/**
1837
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
1838
- * source Observable, then feeds the result of that function along with the second item emitted
1839
- * by an Observable into the same function, and so on until all items have been emitted by the
1840
- * source Observable, emitting the result of each of these iterations as its own sequence.
1841
- * <p>
1842
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/scan.png">
1824
+ * Used by dynamic languages.
1843
1825
*
1844
- * @param <T>
1845
- * the type item emitted by the source Observable
1846
- * @param sequence
1847
- * the source Observable
1848
- * @param accumulator
1849
- * an accumulator function to be invoked on each element from the sequence, whose
1850
- * result will be emitted and used in the next accumulator call (if applicable)
1851
- * @return an Observable that emits a sequence of items that are the result of accumulating the
1852
- * output from the sequence emitted by the source Observable
1853
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
1826
+ * @see #scan(Observable, Func2)
1854
1827
*/
1855
1828
public static <T > Observable <T > scan (final Observable <T > sequence , final Object accumulator ) {
1856
1829
@ SuppressWarnings ("rawtypes" )
@@ -1894,27 +1867,9 @@ public static <T, R> Observable<R> scan(Observable<T> sequence, R initialValue,
1894
1867
}
1895
1868
1896
1869
/**
1897
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
1898
- * source Observable, then feeds the result of that function along with the second item emitted
1899
- * by an Observable into the same function, and so on until all items have been emitted by the
1900
- * source Observable, emitting the result of each of these iterations as its own sequence.
1901
- * <p>
1902
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/scan.png">
1870
+ * Used by dynamic languages.
1903
1871
*
1904
- * @param <T>
1905
- * the type item emitted by the source Observable
1906
- * @param <R>
1907
- * the type returned for each item of the target observable
1908
- * @param sequence
1909
- * the source Observable
1910
- * @param initialValue
1911
- * the initial (seed) accumulator value
1912
- * @param accumulator
1913
- * an accumulator function to be invoked on each element from the sequence, whose
1914
- * result will be emitted and used in the next accumulator call (if applicable)
1915
- * @return an Observable that emits a sequence of items that are the result of accumulating the
1916
- * output from the sequence emitted by the source Observable
1917
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
1872
+ * @see #scan(Observable, Object, Func2)
1918
1873
*/
1919
1874
public static <T , R > Observable <R > scan (final Observable <T > sequence , final R initialValue , final Object accumulator ) {
1920
1875
@ SuppressWarnings ("rawtypes" )
@@ -3232,43 +3187,28 @@ public Observable<T> reduce(Func2<T, T, T> accumulator) {
3232
3187
}
3233
3188
3234
3189
/**
3235
- * @see #reduce(Func2)
3236
- */
3237
- public Observable <T > aggregate (Func2 <T , T , T > accumulator ) {
3238
- return reduce (accumulator );
3239
- }
3240
-
3241
- /**
3242
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
3243
- * source Observable, then feeds the result of that function along with the second item emitted
3244
- * by an Observable into the same function, and so on until all items have been emitted by the
3245
- * source Observable, emitting the final result from the final call to your function as its sole
3246
- * output.
3247
- * <p>
3248
- * This technique, which is called "reduce" here, is sometimes called "fold," "accumulate,"
3249
- * "compress," or "inject" in other programming contexts. Groovy, for instance, has an
3250
- * <code>inject</code> method that does a similar operation on lists.
3251
- * <p>
3252
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/reduce.png">
3190
+ * Used by dynamic languages.
3253
3191
*
3254
- * @param accumulator
3255
- * An accumulator function to be invoked on each element from the sequence, whose result
3256
- * will be used in the next accumulator call (if applicable).
3257
- *
3258
- * @return an Observable that emits a single element from the result of accumulating the output
3259
- * from the list of Observables.
3260
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
3261
- * @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
3192
+ * @see #reduce(Func2)
3262
3193
*/
3263
3194
public Observable <T > reduce (Object accumulator ) {
3264
3195
return reduce (this , accumulator );
3265
3196
}
3266
3197
3267
3198
/**
3268
- * @see #reduce(Object)
3199
+ * @see #reduce(Func2)
3200
+ */
3201
+ public Observable <T > aggregate (Func2 <T , T , T > accumulator ) {
3202
+ return aggregate (this , accumulator );
3203
+ }
3204
+
3205
+ /**
3206
+ * Used by dynamic languages.
3207
+ *
3208
+ * @see #reduce(Func2)
3269
3209
*/
3270
3210
public Observable <T > aggregate (Object accumulator ) {
3271
- return reduce ( accumulator );
3211
+ return aggregate ( this , accumulator );
3272
3212
}
3273
3213
3274
3214
/**
@@ -3300,44 +3240,28 @@ public <R> Observable<R> reduce(R initialValue, Func2<R, T, R> accumulator) {
3300
3240
}
3301
3241
3302
3242
/**
3303
- * @see #reduce(R, Func2)
3243
+ * Used by dynamic languages.
3244
+ *
3245
+ * @see #reduce(Object, Func2)
3304
3246
*/
3305
- public <R > Observable <R > aggregate (R initialValue , Func2 < R , T , R > accumulator ) {
3306
- return reduce (initialValue , accumulator );
3247
+ public <R > Observable <R > reduce (R initialValue , Object accumulator ) {
3248
+ return reduce (this , initialValue , accumulator );
3307
3249
}
3308
3250
3309
3251
/**
3310
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
3311
- * source Observable, then feeds the result of that function along with the second item emitted
3312
- * by an Observable into the same function, and so on until all items have been emitted by the
3313
- * source Observable, emitting the final result from the final call to your function as its sole
3314
- * output.
3315
- * <p>
3316
- * This technique, which is called "reduce" here, is sometimes called "fold," "accumulate,"
3317
- * "compress," or "inject" in other programming contexts. Groovy, for instance, has an
3318
- * <code>inject</code> method that does a similar operation on lists.
3319
- * <p>
3320
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/reduce.png">
3321
- *
3322
- * @param initialValue
3323
- * The initial (seed) accumulator value.
3324
- * @param accumulator
3325
- * An accumulator function to be invoked on each element from the sequence, whose
3326
- * result will be used in the next accumulator call (if applicable).
3327
- * @return an Observable that emits a single element from the result of accumulating the output
3328
- * from the list of Observables.
3329
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
3330
- * @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
3252
+ * @see #reduce(Object, Func2)
3331
3253
*/
3332
- public <R > Observable <R > reduce (R initialValue , Object accumulator ) {
3333
- return reduce (this , initialValue , accumulator );
3254
+ public <R > Observable <R > aggregate (R initialValue , Func2 < R , T , R > accumulator ) {
3255
+ return aggregate (this , initialValue , accumulator );
3334
3256
}
3335
3257
3336
3258
/**
3337
- * @see #reduce(R, Object)
3259
+ * Used by dynamic languages.
3260
+ *
3261
+ * @see #reduce(Object, Func2)
3338
3262
*/
3339
3263
public <R > Observable <R > aggregate (R initialValue , Object accumulator ) {
3340
- return reduce ( initialValue , accumulator );
3264
+ return aggregate ( this , initialValue , accumulator );
3341
3265
}
3342
3266
3343
3267
/**
@@ -3391,23 +3315,9 @@ public Observable<T> sample(long period, TimeUnit unit, Scheduler scheduler) {
3391
3315
}
3392
3316
3393
3317
/**
3394
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
3395
- * source Observable, then feeds the result of that function along with the second item emitted
3396
- * by an Observable into the same function, and so on until all items have been emitted by the
3397
- * source Observable, emitting the result of each of these iterations. It emits the result of
3398
- * each of these iterations as a sequence from the returned Observable. This sort of function is
3399
- * sometimes called an accumulator.
3400
- * <p>
3401
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/scan.png">
3402
- *
3403
- * @param accumulator
3404
- * An accumulator function to be invoked on each element from the sequence whose
3405
- * result will be sent via <code>onNext</code> and used in the next accumulator call
3406
- * (if applicable).
3407
- *
3408
- * @return an Observable sequence whose elements are the result of accumulating the output from
3409
- * the list of Observables.
3410
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
3318
+ * Used by dynamic languages.
3319
+ *
3320
+ * @see #scan(Func2)
3411
3321
*/
3412
3322
public Observable <T > scan (final Object accumulator ) {
3413
3323
return scan (this , accumulator );
@@ -3437,23 +3347,9 @@ public <R> Observable<R> scan(R initialValue, Func2<R, T, R> accumulator) {
3437
3347
}
3438
3348
3439
3349
/**
3440
- * Returns an Observable that applies a function of your choosing to the first item emitted by a
3441
- * source Observable, then feeds the result of that function along with the second item emitted
3442
- * by an Observable into the same function, then feeds the result of that function along with the
3443
- * third item into the same function, and so on, emitting the result of each of these
3444
- * iterations. This sort of function is sometimes called an accumulator.
3445
- * <p>
3446
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/scan.png">
3447
- *
3448
- * @param initialValue
3449
- * The initial (seed) accumulator value.
3450
- * @param accumulator
3451
- * An accumulator function to be invoked on each element from the sequence whose result
3452
- * will be sent via <code>onNext</code> and used in the next accumulator call (if
3453
- * applicable).
3454
- * @return an Observable sequence whose elements are the result of accumulating the output from
3455
- * the list of Observables.
3456
- * @see <a href="http://msdn.microsoft.com/en-us/library/hh211665(v%3Dvs.103).aspx">MSDN: Observable.Scan</a>
3350
+ * Used by dynamic languages.
3351
+ *
3352
+ * @see #scan(Object, Func2)
3457
3353
*/
3458
3354
public <R > Observable <R > scan (final R initialValue , final Object accumulator ) {
3459
3355
return scan (this , initialValue , accumulator );
0 commit comments