From 5386480b0c3dcdf21110f5e1fb019f3e1d084dc1 Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Tue, 10 Sep 2013 21:51:59 -0700 Subject: [PATCH] Change zip method signature from Collection to Iterable Fix javadoc typos. --- rxjava-core/src/main/java/rx/Observable.java | 63 ++++++++++--------- .../main/java/rx/operators/OperationZip.java | 2 +- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/rxjava-core/src/main/java/rx/Observable.java b/rxjava-core/src/main/java/rx/Observable.java index 2ac0f42754..de0d0fe01e 100644 --- a/rxjava-core/src/main/java/rx/Observable.java +++ b/rxjava-core/src/main/java/rx/Observable.java @@ -1891,29 +1891,6 @@ public static Observable from(Future future, long timeout, T return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit)); } - /** - *

- * - *

{@code zip} applies this function in strict sequence, so the first item emitted by the - * new Observable will be the result of the function applied to the first item emitted by {@code w0} and the first item emitted by {@code w1}; the second item emitted by - * the new Observable will be the result of the function applied to the second item emitted by {@code w0} and the second item emitted by {@code w1}; and so forth. - *

- * The resulting {@code Observable} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations - * of the source Observable that emits the fewest items. - * - * @param o1 - * one source Observable - * @param o2 - * another source Observable - * @param zipFunction - * a function that, when applied to an item emitted by each of the source - * Observables, results in an item that will be emitted by the resulting Observable - * @return an Observable that emits the zipped results - */ - public static Observable zip(Observable o1, Observable o2, Func2 zipFunction) { - return create(OperationZip.zip(o1, o2, zipFunction)); - } - /** * Returns an Observable that emits Boolean values that indicate whether the pairs of items * emitted by two source Observables are equal. @@ -1960,6 +1937,31 @@ public static Observable sequenceEqual(Observable firs return zip(first, second, equality); } + /** + * Returns an Observable that emits the results of a function of your choosing applied to + * combinations of two items emitted, in sequence, by two other Observables. + *

+ * + *

{@code zip} applies this function in strict sequence, so the first item emitted by the + * new Observable will be the result of the function applied to the first item emitted by {@code w0} and the first item emitted by {@code w1}; the second item emitted by + * the new Observable will be the result of the function applied to the second item emitted by {@code w0} and the second item emitted by {@code w1}; and so forth. + *

+ * The resulting {@code Observable} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations + * of the source Observable that emits the fewest items. + * + * @param o1 + * one source Observable + * @param o2 + * another source Observable + * @param zipFunction + * a function that, when applied to an item emitted by each of the source + * Observables, results in an item that will be emitted by the resulting Observable + * @return an Observable that emits the zipped results + */ + public static Observable zip(Observable o1, Observable o2, Func2 zipFunction) { + return create(OperationZip.zip(o1, o2, zipFunction)); + } + /** * Returns an Observable that emits the results of a function of your choosing applied to * combinations of three items emitted, in sequence, by three other Observables. @@ -2021,7 +2023,7 @@ public static Observable zip(Observable o1, /** * Returns an Observable that emits the results of a function of your choosing applied to - * combinations of four items emitted, in sequence, by four other Observables. + * combinations of five items emitted, in sequence, by five other Observables. *

* *

{@code zip} applies this function in strict sequence, so the first item emitted by the @@ -2054,7 +2056,7 @@ public static Observable zip(Observable /** * Returns an Observable that emits the results of a function of your choosing applied to - * combinations of four items emitted, in sequence, by four other Observables. + * combinations of six items emitted, in sequence, by six other Observables. *

* *

{@code zip} applies this function in strict sequence, so the first item emitted by the @@ -2090,7 +2092,7 @@ public static Observable zip(Observable * *

{@code zip} applies this function in strict sequence, so the first item emitted by the @@ -2128,7 +2130,7 @@ public static Observable zip(Observable * *

{@code zip} applies this function in strict sequence, so the first item emitted by the @@ -2168,7 +2170,7 @@ public static Observable zip(Observable * *

{@code zip} applies this function in strict sequence, so the first item emitted by the @@ -2680,7 +2682,8 @@ public Observable> window(long timespan, long timeshift, TimeUnit /** * Returns an Observable that emits the results of a function of your choosing applied to - * combinations of four items emitted, in sequence, by four other Observables. + * combinations of N items emitted, in sequence, by N other Observables as provided by an Iterable. + * *

{@code zip} applies this function in strict sequence, so the first item emitted by the * new Observable will be the result of the function applied to the first item emitted by * all of the Observalbes; the second item emitted by the new Observable will be the result of @@ -2727,7 +2730,7 @@ public Observable call(List> wsList) { * Observables, results in an item that will be emitted by the resulting Observable * @return an Observable that emits the zipped results */ - public static Observable zip(Collection> ws, FuncN zipFunction) { + public static Observable zip(Iterable> ws, FuncN zipFunction) { return create(OperationZip.zip(ws, zipFunction)); } diff --git a/rxjava-core/src/main/java/rx/operators/OperationZip.java b/rxjava-core/src/main/java/rx/operators/OperationZip.java index 597fce7c89..517a1faecc 100644 --- a/rxjava-core/src/main/java/rx/operators/OperationZip.java +++ b/rxjava-core/src/main/java/rx/operators/OperationZip.java @@ -147,7 +147,7 @@ public static OnSubscribeFunc zip(Obs return a; } - public static OnSubscribeFunc zip(Collection> ws, FuncN zipFunction) { + public static OnSubscribeFunc zip(Iterable> ws, FuncN zipFunction) { Aggregator a = new Aggregator(zipFunction); for (Observable w : ws) { ZipObserver zipObserver = new ZipObserver(a, w);