@@ -1746,6 +1746,8 @@ public T call(T t1, T t2) {
1746
1746
*
1747
1747
* @param <T>
1748
1748
* the type item emitted by the source Observable
1749
+ * @param <R>
1750
+ * the type returned for each item of the target observable
1749
1751
* @param sequence
1750
1752
* the source Observable
1751
1753
* @param initialValue
@@ -1760,7 +1762,7 @@ public T call(T t1, T t2) {
1760
1762
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
1761
1763
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1762
1764
*/
1763
- public static <T > Observable <T > reduce (Observable <T > sequence , T initialValue , Func2 <T , T , T > accumulator ) {
1765
+ public static <T , R > Observable <R > reduce (Observable <T > sequence , R initialValue , Func2 <R , T , R > accumulator ) {
1764
1766
return takeLast (create (OperationScan .scan (sequence , initialValue , accumulator )), 1 );
1765
1767
}
1766
1768
@@ -1778,6 +1780,8 @@ public static <T> Observable<T> reduce(Observable<T> sequence, T initialValue, F
1778
1780
*
1779
1781
* @param <T>
1780
1782
* the type item emitted by the source Observable
1783
+ * @param <R>
1784
+ * the type returned for each item of the target observable
1781
1785
* @param sequence
1782
1786
* the source Observable
1783
1787
* @param initialValue
@@ -1791,17 +1795,15 @@ public static <T> Observable<T> reduce(Observable<T> sequence, T initialValue, F
1791
1795
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229154(v%3Dvs.103).aspx">MSDN: Observable.Aggregate</a>
1792
1796
* @see <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)">Wikipedia: Fold (higher-order function)</a>
1793
1797
*/
1794
- public static <T > Observable <T > reduce (final Observable <T > sequence , final T initialValue , final Object accumulator ) {
1798
+ public static <T , R > Observable <R > reduce (final Observable <T > sequence , final R initialValue , final Object accumulator ) {
1795
1799
@ SuppressWarnings ("rawtypes" )
1796
1800
final FuncN _f = Functions .from (accumulator );
1797
- return reduce (sequence , initialValue , new Func2 <T , T , T >() {
1798
-
1801
+ return reduce (sequence , initialValue , new Func2 <R , T , R >() {
1799
1802
@ SuppressWarnings ("unchecked" )
1800
1803
@ Override
1801
- public T call (T t1 , T t2 ) {
1802
- return (T ) _f .call (t1 , t2 );
1804
+ public R call (R r , T t ) {
1805
+ return (R ) _f .call (r , t );
1803
1806
}
1804
-
1805
1807
});
1806
1808
}
1807
1809
0 commit comments