|
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;
|
@@ -4405,6 +4406,54 @@ public static Observable<Double> sumDoubles(Observable<Double> source) {
|
4405 | 4406 | return OperationSum.sumDoubles(source);
|
4406 | 4407 | }
|
4407 | 4408 |
|
| 4409 | + /** |
| 4410 | + * Create an Observable that extracts integer values from this Observable via |
| 4411 | + * the provided function and computes the integer sum of the value sequence. |
| 4412 | + * |
| 4413 | + * @param valueExtractor the function to extract an integer from this Observable |
| 4414 | + * @return an Observable that extracts integer values from this Observable via |
| 4415 | + * the provided function and computes the integer sum of the value sequence. |
| 4416 | + */ |
| 4417 | + public Observable<Integer> sumInteger(Func1<? super T, Integer> valueExtractor) { |
| 4418 | + return create(new OperationSum.SumIntegerExtractor<T>(this, valueExtractor)); |
| 4419 | + } |
| 4420 | + |
| 4421 | + /** |
| 4422 | + * Create an Observable that extracts long values from this Observable via |
| 4423 | + * the provided function and computes the long sum of the value sequence. |
| 4424 | + * |
| 4425 | + * @param valueExtractor the function to extract an long from this Observable |
| 4426 | + * @return an Observable that extracts long values from this Observable via |
| 4427 | + * the provided function and computes the long sum of the value sequence. |
| 4428 | + */ |
| 4429 | + public Observable<Long> sumLong(Func1<? super T, Long> valueExtractor) { |
| 4430 | + return create(new OperationSum.SumLongExtractor<T>(this, valueExtractor)); |
| 4431 | + } |
| 4432 | + |
| 4433 | + /** |
| 4434 | + * Create an Observable that extracts float values from this Observable via |
| 4435 | + * the provided function and computes the float sum of the value sequence. |
| 4436 | + * |
| 4437 | + * @param valueExtractor the function to extract an float from this Observable |
| 4438 | + * @return an Observable that extracts float values from this Observable via |
| 4439 | + * the provided function and computes the float sum of the value sequence. |
| 4440 | + */ |
| 4441 | + public Observable<Float> sumFloat(Func1<? super T, Float> valueExtractor) { |
| 4442 | + return create(new OperationSum.SumFloatExtractor<T>(this, valueExtractor)); |
| 4443 | + } |
| 4444 | + |
| 4445 | + /** |
| 4446 | + * Create an Observable that extracts double values from this Observable via |
| 4447 | + * the provided function and computes the double sum of the value sequence. |
| 4448 | + * |
| 4449 | + * @param valueExtractor the function to extract an double from this Observable |
| 4450 | + * @return an Observable that extracts double values from this Observable via |
| 4451 | + * the provided function and computes the double sum of the value sequence. |
| 4452 | + */ |
| 4453 | + public Observable<Double> sumDouble(Func1<? super T, Double> valueExtractor) { |
| 4454 | + return create(new OperationSum.SumDoubleExtractor<T>(this, valueExtractor)); |
| 4455 | + } |
| 4456 | + |
4408 | 4457 | /**
|
4409 | 4458 | * Returns an Observable that computes the average of the Integers emitted
|
4410 | 4459 | * by the source Observable.
|
@@ -4470,6 +4519,54 @@ public static Observable<Double> averageDoubles(Observable<Double> source) {
|
4470 | 4519 | return OperationAverage.averageDoubles(source);
|
4471 | 4520 | }
|
4472 | 4521 |
|
| 4522 | + /** |
| 4523 | + * Create an Observable that extracts integer values from this Observable via |
| 4524 | + * the provided function and computes the integer average of the value sequence. |
| 4525 | + * |
| 4526 | + * @param valueExtractor the function to extract an integer from this Observable |
| 4527 | + * @return an Observable that extracts integer values from this Observable via |
| 4528 | + * the provided function and computes the integer average of the value sequence. |
| 4529 | + */ |
| 4530 | + public Observable<Integer> averageInteger(Func1<? super T, Integer> valueExtractor) { |
| 4531 | + return create(new OperationAverage.AverageIntegerExtractor<T>(this, valueExtractor)); |
| 4532 | + } |
| 4533 | + |
| 4534 | + /** |
| 4535 | + * Create an Observable that extracts long values from this Observable via |
| 4536 | + * the provided function and computes the long average of the value sequence. |
| 4537 | + * |
| 4538 | + * @param valueExtractor the function to extract an long from this Observable |
| 4539 | + * @return an Observable that extracts long values from this Observable via |
| 4540 | + * the provided function and computes the long average of the value sequence. |
| 4541 | + */ |
| 4542 | + public Observable<Long> averageLong(Func1<? super T, Long> valueExtractor) { |
| 4543 | + return create(new OperationAverage.AverageLongExtractor<T>(this, valueExtractor)); |
| 4544 | + } |
| 4545 | + |
| 4546 | + /** |
| 4547 | + * Create an Observable that extracts float values from this Observable via |
| 4548 | + * the provided function and computes the float average of the value sequence. |
| 4549 | + * |
| 4550 | + * @param valueExtractor the function to extract an float from this Observable |
| 4551 | + * @return an Observable that extracts float values from this Observable via |
| 4552 | + * the provided function and computes the float average of the value sequence. |
| 4553 | + */ |
| 4554 | + public Observable<Float> averageFloat(Func1<? super T, Float> valueExtractor) { |
| 4555 | + return create(new OperationAverage.AverageFloatExtractor<T>(this, valueExtractor)); |
| 4556 | + } |
| 4557 | + |
| 4558 | + /** |
| 4559 | + * Create an Observable that extracts double values from this Observable via |
| 4560 | + * the provided function and computes the double average of the value sequence. |
| 4561 | + * |
| 4562 | + * @param valueExtractor the function to extract an double from this Observable |
| 4563 | + * @return an Observable that extracts double values from this Observable via |
| 4564 | + * the provided function and computes the double average of the value sequence. |
| 4565 | + */ |
| 4566 | + public Observable<Double> averageDouble(Func1<? super T, Double> valueExtractor) { |
| 4567 | + return create(new OperationAverage.AverageDoubleExtractor<T>(this, valueExtractor)); |
| 4568 | + } |
| 4569 | + |
4473 | 4570 | /**
|
4474 | 4571 | * Returns an Observable that emits the minimum item emitted by the source
|
4475 | 4572 | * Observable. If there is more than one such item, it returns the
|
@@ -5243,6 +5340,49 @@ public <R> Observable<R> reduce(R initialValue, Func2<R, ? super T, R> accumulat
|
5243 | 5340 | public <R> Observable<R> aggregate(R initialValue, Func2<R, ? super T, R> accumulator) {
|
5244 | 5341 | return reduce(initialValue, accumulator);
|
5245 | 5342 | }
|
| 5343 | + |
| 5344 | + /** |
| 5345 | + * Create an Observable that aggregates the source values with the given accumulator |
| 5346 | + * function and projects the final result via the resultselector. |
| 5347 | + * <p> |
| 5348 | + * Works like the {@link #aggregate(java.lang.Object, rx.util.functions.Func2)} projected |
| 5349 | + * with {@link #map(rx.util.functions.Func1)} without the overhead of some helper |
| 5350 | + * operators. |
| 5351 | + * @param <U> the intermediate (accumulator) type |
| 5352 | + * @param <V> the result type |
| 5353 | + * @param seed the initial value of the accumulator |
| 5354 | + * @param accumulator the function that takes the current accumulator value, |
| 5355 | + * the current emitted value and returns a (new) accumulated value. |
| 5356 | + * @param resultSelector the selector to project the final value of the accumulator |
| 5357 | + * @return an Observable that aggregates the source values with the given accumulator |
| 5358 | + * function and projects the final result via the resultselector |
| 5359 | + */ |
| 5360 | + public <U, V> Observable<V> aggregate( |
| 5361 | + U seed, Func2<U, ? super T, U> accumulator, |
| 5362 | + Func1<? super U, ? extends V> resultSelector) { |
| 5363 | + return create(new OperationAggregate.AggregateSelector<T, U, V>(this, seed, accumulator, resultSelector)); |
| 5364 | + } |
| 5365 | + |
| 5366 | + /** |
| 5367 | + * Create an Observable that aggregates the source values with the given indexed accumulator |
| 5368 | + * function and projects the final result via the indexed resultselector. |
| 5369 | + * |
| 5370 | + * @param <U> the intermediate (accumulator) type |
| 5371 | + * @param <V> the result type |
| 5372 | + * @param seed the initial value of the accumulator |
| 5373 | + * @param accumulator the function that takes the current accumulator value, |
| 5374 | + * the current emitted value and returns a (new) accumulated value. |
| 5375 | + * @param resultSelector the selector to project the final value of the accumulator, where |
| 5376 | + * the second argument is the total number of elements accumulated |
| 5377 | + * @return an Observable that aggregates the source values with the given indexed accumulator |
| 5378 | + * function and projects the final result via the indexed resultselector. |
| 5379 | + */ |
| 5380 | + public <U, V> Observable<V> aggregateIndexed( |
| 5381 | + U seed, Func3<U, ? super T, ? super Integer, U> accumulator, |
| 5382 | + Func2<? super U, ? super Integer, ? extends V> resultSelector |
| 5383 | + ) { |
| 5384 | + return create(new OperationAggregate.AggregateIndexedSelector<T, U, V>(this, seed, accumulator, resultSelector)); |
| 5385 | + } |
5246 | 5386 |
|
5247 | 5387 | /**
|
5248 | 5388 | * Returns an Observable that applies a function of your choosing to the
|
|
0 commit comments