|
32 | 32 | import rx.observables.BlockingObservable;
|
33 | 33 | import rx.observables.ConnectableObservable;
|
34 | 34 | import rx.observables.GroupedObservable;
|
| 35 | +import rx.operators.OperationAggregate; |
35 | 36 | import rx.operators.OperationAll;
|
36 | 37 | import rx.operators.OperationAmb;
|
37 | 38 | import rx.operators.OperationAny;
|
@@ -4118,6 +4119,54 @@ public static Observable<Double> sumDoubles(Observable<Double> source) {
|
4118 | 4119 | return OperationSum.sumDoubles(source);
|
4119 | 4120 | }
|
4120 | 4121 |
|
| 4122 | + /** |
| 4123 | + * Create an Observable that extracts integer values from this Observable via |
| 4124 | + * the provided function and computes the integer sum of the value sequence. |
| 4125 | + * |
| 4126 | + * @param valueExtractor the function to extract an integer from this Observable |
| 4127 | + * @return an Observable that extracts integer values from this Observable via |
| 4128 | + * the provided function and computes the integer sum of the value sequence. |
| 4129 | + */ |
| 4130 | + public Observable<Integer> sumInteger(Func1<? super T, Integer> valueExtractor) { |
| 4131 | + return create(new OperationSum.SumIntegerExtractor<T>(this, valueExtractor)); |
| 4132 | + } |
| 4133 | + |
| 4134 | + /** |
| 4135 | + * Create an Observable that extracts long values from this Observable via |
| 4136 | + * the provided function and computes the long sum of the value sequence. |
| 4137 | + * |
| 4138 | + * @param valueExtractor the function to extract an long from this Observable |
| 4139 | + * @return an Observable that extracts long values from this Observable via |
| 4140 | + * the provided function and computes the long sum of the value sequence. |
| 4141 | + */ |
| 4142 | + public Observable<Long> sumLong(Func1<? super T, Long> valueExtractor) { |
| 4143 | + return create(new OperationSum.SumLongExtractor<T>(this, valueExtractor)); |
| 4144 | + } |
| 4145 | + |
| 4146 | + /** |
| 4147 | + * Create an Observable that extracts float values from this Observable via |
| 4148 | + * the provided function and computes the float sum of the value sequence. |
| 4149 | + * |
| 4150 | + * @param valueExtractor the function to extract an float from this Observable |
| 4151 | + * @return an Observable that extracts float values from this Observable via |
| 4152 | + * the provided function and computes the float sum of the value sequence. |
| 4153 | + */ |
| 4154 | + public Observable<Float> sumFloat(Func1<? super T, Float> valueExtractor) { |
| 4155 | + return create(new OperationSum.SumFloatExtractor<T>(this, valueExtractor)); |
| 4156 | + } |
| 4157 | + |
| 4158 | + /** |
| 4159 | + * Create an Observable that extracts double values from this Observable via |
| 4160 | + * the provided function and computes the double sum of the value sequence. |
| 4161 | + * |
| 4162 | + * @param valueExtractor the function to extract an double from this Observable |
| 4163 | + * @return an Observable that extracts double values from this Observable via |
| 4164 | + * the provided function and computes the double sum of the value sequence. |
| 4165 | + */ |
| 4166 | + public Observable<Double> sumDouble(Func1<? super T, Double> valueExtractor) { |
| 4167 | + return create(new OperationSum.SumDoubleExtractor<T>(this, valueExtractor)); |
| 4168 | + } |
| 4169 | + |
4121 | 4170 | /**
|
4122 | 4171 | * Returns an Observable that computes the average of the Integers emitted
|
4123 | 4172 | * by the source Observable.
|
@@ -4183,6 +4232,54 @@ public static Observable<Double> averageDoubles(Observable<Double> source) {
|
4183 | 4232 | return OperationAverage.averageDoubles(source);
|
4184 | 4233 | }
|
4185 | 4234 |
|
| 4235 | + /** |
| 4236 | + * Create an Observable that extracts integer values from this Observable via |
| 4237 | + * the provided function and computes the integer average of the value sequence. |
| 4238 | + * |
| 4239 | + * @param valueExtractor the function to extract an integer from this Observable |
| 4240 | + * @return an Observable that extracts integer values from this Observable via |
| 4241 | + * the provided function and computes the integer average of the value sequence. |
| 4242 | + */ |
| 4243 | + public Observable<Integer> averageInteger(Func1<? super T, Integer> valueExtractor) { |
| 4244 | + return create(new OperationAverage.AverageIntegerExtractor<T>(this, valueExtractor)); |
| 4245 | + } |
| 4246 | + |
| 4247 | + /** |
| 4248 | + * Create an Observable that extracts long values from this Observable via |
| 4249 | + * the provided function and computes the long average of the value sequence. |
| 4250 | + * |
| 4251 | + * @param valueExtractor the function to extract an long from this Observable |
| 4252 | + * @return an Observable that extracts long values from this Observable via |
| 4253 | + * the provided function and computes the long average of the value sequence. |
| 4254 | + */ |
| 4255 | + public Observable<Long> averageLong(Func1<? super T, Long> valueExtractor) { |
| 4256 | + return create(new OperationAverage.AverageLongExtractor<T>(this, valueExtractor)); |
| 4257 | + } |
| 4258 | + |
| 4259 | + /** |
| 4260 | + * Create an Observable that extracts float values from this Observable via |
| 4261 | + * the provided function and computes the float average of the value sequence. |
| 4262 | + * |
| 4263 | + * @param valueExtractor the function to extract an float from this Observable |
| 4264 | + * @return an Observable that extracts float values from this Observable via |
| 4265 | + * the provided function and computes the float average of the value sequence. |
| 4266 | + */ |
| 4267 | + public Observable<Float> averageFloat(Func1<? super T, Float> valueExtractor) { |
| 4268 | + return create(new OperationAverage.AverageFloatExtractor<T>(this, valueExtractor)); |
| 4269 | + } |
| 4270 | + |
| 4271 | + /** |
| 4272 | + * Create an Observable that extracts double values from this Observable via |
| 4273 | + * the provided function and computes the double average of the value sequence. |
| 4274 | + * |
| 4275 | + * @param valueExtractor the function to extract an double from this Observable |
| 4276 | + * @return an Observable that extracts double values from this Observable via |
| 4277 | + * the provided function and computes the double average of the value sequence. |
| 4278 | + */ |
| 4279 | + public Observable<Double> averageDouble(Func1<? super T, Double> valueExtractor) { |
| 4280 | + return create(new OperationAverage.AverageDoubleExtractor<T>(this, valueExtractor)); |
| 4281 | + } |
| 4282 | + |
4186 | 4283 | /**
|
4187 | 4284 | * Returns an Observable that emits the minimum item emitted by the source
|
4188 | 4285 | * Observable. If there is more than one such item, it returns the
|
@@ -4954,6 +5051,49 @@ public <R> Observable<R> reduce(R initialValue, Func2<R, ? super T, R> accumulat
|
4954 | 5051 | public <R> Observable<R> aggregate(R initialValue, Func2<R, ? super T, R> accumulator) {
|
4955 | 5052 | return reduce(initialValue, accumulator);
|
4956 | 5053 | }
|
| 5054 | + |
| 5055 | + /** |
| 5056 | + * Create an Observable that aggregates the source values with the given accumulator |
| 5057 | + * function and projects the final result via the resultselector. |
| 5058 | + * <p> |
| 5059 | + * Works like the {@link #aggregate(java.lang.Object, rx.util.functions.Func2)} projected |
| 5060 | + * with {@link #map(rx.util.functions.Func1)} without the overhead of some helper |
| 5061 | + * operators. |
| 5062 | + * @param <U> the intermediate (accumulator) type |
| 5063 | + * @param <V> the result type |
| 5064 | + * @param seed the initial value of the accumulator |
| 5065 | + * @param accumulator the function that takes the current accumulator value, |
| 5066 | + * the current emitted value and returns a (new) accumulated value. |
| 5067 | + * @param resultSelector the selector to project the final value of the accumulator |
| 5068 | + * @return an Observable that aggregates the source values with the given accumulator |
| 5069 | + * function and projects the final result via the resultselector |
| 5070 | + */ |
| 5071 | + public <U, V> Observable<V> aggregate( |
| 5072 | + U seed, Func2<U, ? super T, U> accumulator, |
| 5073 | + Func1<? super U, ? extends V> resultSelector) { |
| 5074 | + return create(new OperationAggregate.AggregateSelector<T, U, V>(this, seed, accumulator, resultSelector)); |
| 5075 | + } |
| 5076 | + |
| 5077 | + /** |
| 5078 | + * Create an Observable that aggregates the source values with the given indexed accumulator |
| 5079 | + * function and projects the final result via the indexed resultselector. |
| 5080 | + * |
| 5081 | + * @param <U> the intermediate (accumulator) type |
| 5082 | + * @param <V> the result type |
| 5083 | + * @param seed the initial value of the accumulator |
| 5084 | + * @param accumulator the function that takes the current accumulator value, |
| 5085 | + * the current emitted value and returns a (new) accumulated value. |
| 5086 | + * @param resultSelector the selector to project the final value of the accumulator, where |
| 5087 | + * the second argument is the total number of elements accumulated |
| 5088 | + * @return an Observable that aggregates the source values with the given indexed accumulator |
| 5089 | + * function and projects the final result via the indexed resultselector. |
| 5090 | + */ |
| 5091 | + public <U, V> Observable<V> aggregateIndexed( |
| 5092 | + U seed, Func3<U, ? super T, ? super Integer, U> accumulator, |
| 5093 | + Func2<? super U, ? super Integer, ? extends V> resultSelector |
| 5094 | + ) { |
| 5095 | + return create(new OperationAggregate.AggregateIndexedSelector<T, U, V>(this, seed, accumulator, resultSelector)); |
| 5096 | + } |
4957 | 5097 |
|
4958 | 5098 | /**
|
4959 | 5099 | * Returns an Observable that applies a function of your choosing to the
|
|
0 commit comments