Skip to content

Commit 0e6be52

Browse files
committed
Adding diagrams, improving javadocs for sumFoo/averageFoo operators.
1 parent 6949e7b commit 0e6be52

File tree

1 file changed

+97
-41
lines changed

1 file changed

+97
-41
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 97 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4412,49 +4412,77 @@ public static Observable<Double> sumDoubles(Observable<Double> source) {
44124412
return OperationSum.sumDoubles(source);
44134413
}
44144414

4415-
/**
4416-
* Create an Observable that extracts integer values from this Observable via
4417-
* the provided function and computes the integer sum of the value sequence.
4415+
/**
4416+
* Create an Observable that extracts an integer from each of the items
4417+
* emitted by the source Observable via a function you specify, and then
4418+
* emits the sum of these integers.
4419+
* <p>
4420+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/sum.f.png">
44184421
*
4419-
* @param valueExtractor the function to extract an integer from this Observable
4420-
* @return an Observable that extracts integer values from this Observable via
4421-
* the provided function and computes the integer sum of the value sequence.
4422+
* @param valueExtractor the function to extract an integer from each item
4423+
* emitted by the source Observable
4424+
* @return an Observable that emits the integer sum of the integer values
4425+
* corresponding to the items emitted by the source Observable
4426+
* transformed by the provided function
4427+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#sum">RxJava Wiki: sumInteger()</a>
4428+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.sum.aspx">MSDN: Observable.Sum</a>
44224429
*/
44234430
public Observable<Integer> sumInteger(Func1<? super T, Integer> valueExtractor) {
44244431
return create(new OperationSum.SumIntegerExtractor<T>(this, valueExtractor));
44254432
}
44264433

44274434
/**
4428-
* Create an Observable that extracts long values from this Observable via
4429-
* the provided function and computes the long sum of the value sequence.
4435+
* Create an Observable that extracts a long from each of the items emitted
4436+
* by the source Observable via a function you specify, and then emits the
4437+
* sum of these longs.
4438+
* <p>
4439+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/sum.f.png">
44304440
*
4431-
* @param valueExtractor the function to extract an long from this Observable
4432-
* @return an Observable that extracts long values from this Observable via
4433-
* the provided function and computes the long sum of the value sequence.
4441+
* @param valueExtractor the function to extract a long from each item
4442+
* emitted by the source Observable
4443+
* @return an Observable that emits the long sum of the integer values
4444+
* corresponding to the items emitted by the source Observable
4445+
* transformed by the provided function
4446+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#sum">RxJava Wiki: sumLong()</a>
4447+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.sum.aspx">MSDN: Observable.Sum</a>
44344448
*/
44354449
public Observable<Long> sumLong(Func1<? super T, Long> valueExtractor) {
44364450
return create(new OperationSum.SumLongExtractor<T>(this, valueExtractor));
44374451
}
44384452

44394453
/**
4440-
* Create an Observable that extracts float values from this Observable via
4441-
* the provided function and computes the float sum of the value sequence.
4454+
* Create an Observable that extracts a float from each of the items emitted
4455+
* by the source Observable via a function you specify, and then emits the
4456+
* sum of these floats.
4457+
* <p>
4458+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/sum.f.png">
44424459
*
4443-
* @param valueExtractor the function to extract an float from this Observable
4444-
* @return an Observable that extracts float values from this Observable via
4445-
* the provided function and computes the float sum of the value sequence.
4460+
* @param valueExtractor the function to extract a float from each item
4461+
* emitted by the source Observable
4462+
* @return an Observable that emits the float sum of the integer values
4463+
* corresponding to the items emitted by the source Observable
4464+
* transformed by the provided function
4465+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#sum">RxJava Wiki: sumFloat()</a>
4466+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.sum.aspx">MSDN: Observable.Sum</a>
44464467
*/
44474468
public Observable<Float> sumFloat(Func1<? super T, Float> valueExtractor) {
44484469
return create(new OperationSum.SumFloatExtractor<T>(this, valueExtractor));
44494470
}
44504471

44514472
/**
4452-
* Create an Observable that extracts double values from this Observable via
4453-
* the provided function and computes the double sum of the value sequence.
4473+
* Create an Observable that extracts a double from each of the items
4474+
* emitted by the source Observable via a function you specify, and then
4475+
* emits the sum of these doubles.
4476+
* <p>
4477+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/sum.f.png">
44544478
*
4455-
* @param valueExtractor the function to extract an double from this Observable
4456-
* @return an Observable that extracts double values from this Observable via
4457-
* the provided function and computes the double sum of the value sequence.
4479+
* @param valueExtractor the function to extract a double from each item
4480+
* emitted by the source Observable
4481+
* @return an Observable that emits the double sum of the integer values
4482+
* corresponding to the items emitted by the source Observable
4483+
* transformed by the provided function
4484+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#sum">RxJava Wiki: sumDouble()</a>
4485+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.sum.aspx">MSDN: Observable.Sum</a>
44584486
*/
44594487
public Observable<Double> sumDouble(Func1<? super T, Double> valueExtractor) {
44604488
return create(new OperationSum.SumDoubleExtractor<T>(this, valueExtractor));
@@ -4526,48 +4554,76 @@ public static Observable<Double> averageDoubles(Observable<Double> source) {
45264554
}
45274555

45284556
/**
4529-
* Create an Observable that extracts integer values from this Observable via
4530-
* the provided function and computes the integer average of the value sequence.
4557+
* Create an Observable that transforms items emitted by the source
4558+
* Observable into integers by using a function you provide and then emits
4559+
* the integer average of the complete sequence of transformed values.
4560+
* <p>
4561+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/average.f.png">
45314562
*
4532-
* @param valueExtractor the function to extract an integer from this Observable
4533-
* @return an Observable that extracts integer values from this Observable via
4534-
* the provided function and computes the integer average of the value sequence.
4563+
* @param valueExtractor the function to transform an item emitted by the
4564+
* source Observable into an integer
4565+
* @return an Observable that emits the integer average of the complete
4566+
* sequence of items emitted by the source Observable when
4567+
* transformed into integers by the specified function
4568+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#average">RxJava Wiki: averageInteger()</a>
4569+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
45354570
*/
45364571
public Observable<Integer> averageInteger(Func1<? super T, Integer> valueExtractor) {
45374572
return create(new OperationAverage.AverageIntegerExtractor<T>(this, valueExtractor));
45384573
}
45394574

45404575
/**
4541-
* Create an Observable that extracts long values from this Observable via
4542-
* the provided function and computes the long average of the value sequence.
4576+
* Create an Observable that transforms items emitted by the source
4577+
* Observable into longs by using a function you provide and then emits
4578+
* the long average of the complete sequence of transformed values.
4579+
* <p>
4580+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/average.f.png">
45434581
*
4544-
* @param valueExtractor the function to extract an long from this Observable
4545-
* @return an Observable that extracts long values from this Observable via
4546-
* the provided function and computes the long average of the value sequence.
4582+
* @param valueExtractor the function to transform an item emitted by the
4583+
* source Observable into a long
4584+
* @return an Observable that emits the long average of the complete
4585+
* sequence of items emitted by the source Observable when
4586+
* transformed into longs by the specified function
4587+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#average">RxJava Wiki: averageLong()</a>
4588+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
45474589
*/
45484590
public Observable<Long> averageLong(Func1<? super T, Long> valueExtractor) {
45494591
return create(new OperationAverage.AverageLongExtractor<T>(this, valueExtractor));
45504592
}
45514593

45524594
/**
4553-
* Create an Observable that extracts float values from this Observable via
4554-
* the provided function and computes the float average of the value sequence.
4595+
* Create an Observable that transforms items emitted by the source
4596+
* Observable into floats by using a function you provide and then emits
4597+
* the float average of the complete sequence of transformed values.
4598+
* <p>
4599+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/average.f.png">
45554600
*
4556-
* @param valueExtractor the function to extract an float from this Observable
4557-
* @return an Observable that extracts float values from this Observable via
4558-
* the provided function and computes the float average of the value sequence.
4601+
* @param valueExtractor the function to transform an item emitted by the
4602+
* source Observable into a float
4603+
* @return an Observable that emits the float average of the complete
4604+
* sequence of items emitted by the source Observable when
4605+
* transformed into floats by the specified function
4606+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#average">RxJava Wiki: averageFloat()</a>
4607+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
45594608
*/
45604609
public Observable<Float> averageFloat(Func1<? super T, Float> valueExtractor) {
45614610
return create(new OperationAverage.AverageFloatExtractor<T>(this, valueExtractor));
45624611
}
45634612

45644613
/**
4565-
* Create an Observable that extracts double values from this Observable via
4566-
* the provided function and computes the double average of the value sequence.
4614+
* Create an Observable that transforms items emitted by the source
4615+
* Observable into doubles by using a function you provide and then emits
4616+
* the double average of the complete sequence of transformed values.
4617+
* <p>
4618+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/average.f.png">
45674619
*
4568-
* @param valueExtractor the function to extract an double from this Observable
4569-
* @return an Observable that extracts double values from this Observable via
4570-
* the provided function and computes the double average of the value sequence.
4620+
* @param valueExtractor the function to transform an item emitted by the
4621+
* source Observable into a double
4622+
* @return an Observable that emits the double average of the complete
4623+
* sequence of items emitted by the source Observable when
4624+
* transformed into doubles by the specified function
4625+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#average">RxJava Wiki: averageDouble()</a>
4626+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
45714627
*/
45724628
public Observable<Double> averageDouble(Func1<? super T, Double> valueExtractor) {
45734629
return create(new OperationAverage.AverageDoubleExtractor<T>(this, valueExtractor));

0 commit comments

Comments
 (0)