@SuppressWarnings("unchecked") public FlowableToListSingle(Flowable<T> source) { this(source, (Callable<U>)ArrayListSupplier.asCallable()); }
Callable<Map<K, Collection<V>>> mapSupplier ) { return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.<V, K>asFunction());
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits connected, non-overlapping buffers. It emits the current buffer and replaces it with a * new buffer whenever the ObservableSource produced by the specified {@code closingIndicator} emits an item. * <p> * <img width="640" height="395" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer1.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <B> the value type of the boundary-providing ObservableSource * @param boundarySupplier * a {@link Callable} that produces an ObservableSource that governs the boundary between buffers. * Whenever the source {@code ObservableSource} emits an item, {@code buffer} emits the current buffer and * begins to fill a new one * @return an Observable that emits a connected, non-overlapping buffer of items from the source ObservableSource * each time the ObservableSource created with the {@code closingIndicator} argument emits an item * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <B> Observable<List<T>> buffer(Callable<? extends ObservableSource<B>> boundarySupplier) { return buffer(boundarySupplier, ArrayListSupplier.<T>asCallable()); }
Callable<Map<K, Collection<V>>> mapSupplier ) { return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.<V, K>asFunction());
/** * Returns an Observable that emits non-overlapping buffered items from the source ObservableSource each time the * specified boundary ObservableSource emits an item. * <p> * <img width="640" height="395" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer8.png" alt=""> * <p> * Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the * latest buffer and complete. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <B> * the boundary value type (ignored) * @param boundary * the boundary ObservableSource * @return an Observable that emits buffered items from the source ObservableSource when the boundary ObservableSource * emits an item * @see #buffer(ObservableSource, int) * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary) { return buffer(boundary, ArrayListSupplier.<T>asCallable()); }
/** * Returns a Single that emits a single HashMap that contains an ArrayList of values extracted by a * specified {@code valueSelector} function from items emitted by the source ObservableSource, keyed by a * specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMultiMap.2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMultimap} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <K> the key type of the Map * @param <V> the value type of the Map * @param keySelector * the function that extracts a key from the source items to be used as key in the HashMap * @param valueSelector * the function that extracts a value from the source items to be used as value in the HashMap * @return a Single that emits a single item: a HashMap that contains an ArrayList of items mapped from * the source ObservableSource * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <K, V> Single<Map<K, Collection<V>>> toMultimap(Function<? super T, ? extends K> keySelector, Function<? super T, ? extends V> valueSelector) { Callable<Map<K, Collection<V>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<V>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); }
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits buffers every {@code skip} items, each containing {@code count} items. When the source * ObservableSource completes or encounters an error, the resulting ObservableSource emits the current buffer and * propagates the notification from the source ObservableSource. * <p> * <img width="640" height="320" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer4.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param count * the maximum size of each buffer before it should be emitted * @param skip * how many items emitted by the source ObservableSource should be skipped before starting a new * buffer. Note that when {@code skip} and {@code count} are equal, this is the same operation as * {@link #buffer(int)}. * @return an Observable that emits buffers for every {@code skip} item from the source ObservableSource and * containing at most {@code count} items * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Observable<List<T>> buffer(int count, int skip) { return buffer(count, skip, ArrayListSupplier.<T>asCallable()); }
/** * Returns a Single that emits a single HashMap that contains an ArrayList of values extracted by a * specified {@code valueSelector} function from items emitted by the source ObservableSource, keyed by a * specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMultiMap.2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMultimap} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <K> the key type of the Map * @param <V> the value type of the Map * @param keySelector * the function that extracts a key from the source items to be used as key in the HashMap * @param valueSelector * the function that extracts a value from the source items to be used as value in the HashMap * @return a Single that emits a single item: a HashMap that contains an ArrayList of items mapped from * the source ObservableSource * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <K, V> Single<Map<K, Collection<V>>> toMultimap(Function<? super T, ? extends K> keySelector, Function<? super T, ? extends V> valueSelector) { Callable<Map<K, Collection<V>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<V>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); }
/** * Returns an Observable that emits non-overlapping buffered items from the source ObservableSource each time the * specified boundary ObservableSource emits an item. * <p> * <img width="640" height="395" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer8.png" alt=""> * <p> * Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the * latest buffer and complete. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <B> * the boundary value type (ignored) * @param boundary * the boundary ObservableSource * @return an Observable that emits buffered items from the source ObservableSource when the boundary ObservableSource * emits an item * @see #buffer(ObservableSource, int) * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary) { return buffer(boundary, ArrayListSupplier.<T>asCallable()); }
Callable<Map<K, Collection<V>>> mapSupplier ) { return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.<V, K>asFunction());
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits connected, non-overlapping buffers. It emits the current buffer and replaces it with a * new buffer whenever the ObservableSource produced by the specified {@code closingIndicator} emits an item. * <p> * <img width="640" height="395" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer1.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <B> the value type of the boundary-providing ObservableSource * @param boundarySupplier * a {@link Callable} that produces an ObservableSource that governs the boundary between buffers. * Whenever the source {@code ObservableSource} emits an item, {@code buffer} emits the current buffer and * begins to fill a new one * @return an Observable that emits a connected, non-overlapping buffer of items from the source ObservableSource * each time the ObservableSource created with the {@code closingIndicator} argument emits an item * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <B> Observable<List<T>> buffer(Callable<? extends ObservableSource<B>> boundarySupplier) { return buffer(boundarySupplier, ArrayListSupplier.<T>asCallable()); }
Callable<Map<K, Collection<V>>> mapSupplier ) { return toMultimap(source, keySelector, valueSelector, mapSupplier, ArrayListSupplier.<V, K>asFunction());
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits connected, non-overlapping buffers, each of a fixed duration specified by the * {@code timespan} argument and on the specified {@code scheduler}. When the source ObservableSource completes or * encounters an error, the resulting ObservableSource emits the current buffer and propagates the notification * from the source ObservableSource. * <p> * <img width="640" height="320" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer5.s.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>You specify which {@link Scheduler} this operator will use</dd> * </dl> * * @param timespan * the period of time each buffer collects items before it is emitted and replaced with a new * buffer * @param unit * the unit of time which applies to the {@code timespan} argument * @param scheduler * the {@link Scheduler} to use when determining the end and start of a buffer * @return an Observable that emits connected, non-overlapping buffers of items emitted by the source * ObservableSource within a fixed duration * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) public final Observable<List<T>> buffer(long timespan, TimeUnit unit, Scheduler scheduler) { return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.<T>asCallable(), false); }
/** * Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the * source ObservableSource keyed by a specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMultiMap.2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMultimap} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <K> the key type of the Map * @param keySelector * the function that extracts the key from the source items to be used as key in the HashMap * @return a Single that emits a single item: a HashMap that contains an ArrayList of items mapped from * the source ObservableSource * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <K> Single<Map<K, Collection<T>>> toMultimap(Function<? super T, ? extends K> keySelector) { @SuppressWarnings({ "rawtypes", "unchecked" }) Function<? super T, ? extends T> valueSelector = (Function)Functions.identity(); Callable<Map<K, Collection<T>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<T>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); }
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits connected, non-overlapping buffers, each of a fixed duration specified by the * {@code timespan} argument and on the specified {@code scheduler}. When the source ObservableSource completes or * encounters an error, the resulting ObservableSource emits the current buffer and propagates the notification * from the source ObservableSource. * <p> * <img width="640" height="320" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer5.s.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>You specify which {@link Scheduler} this operator will use</dd> * </dl> * * @param timespan * the period of time each buffer collects items before it is emitted and replaced with a new * buffer * @param unit * the unit of time which applies to the {@code timespan} argument * @param scheduler * the {@link Scheduler} to use when determining the end and start of a buffer * @return an Observable that emits connected, non-overlapping buffers of items emitted by the source * ObservableSource within a fixed duration * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) public final Observable<List<T>> buffer(long timespan, TimeUnit unit, Scheduler scheduler) { return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.<T>asCallable(), false); }
/** * Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the * source ObservableSource keyed by a specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMultiMap.2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMultimap} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <K> the key type of the Map * @param keySelector * the function that extracts the key from the source items to be used as key in the HashMap * @return a Single that emits a single item: a HashMap that contains an ArrayList of items mapped from * the source ObservableSource * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <K> Single<Map<K, Collection<T>>> toMultimap(Function<? super T, ? extends K> keySelector) { @SuppressWarnings({ "rawtypes", "unchecked" }) Function<? super T, ? extends T> valueSelector = (Function)Functions.identity(); Callable<Map<K, Collection<T>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<T>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); }
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits buffers that it creates when the specified {@code openingIndicator} ObservableSource emits an * item, and closes when the ObservableSource returned from {@code closingIndicator} emits an item. * <p> * <img width="640" height="470" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <TOpening> the element type of the buffer-opening ObservableSource * @param <TClosing> the element type of the individual buffer-closing ObservableSources * @param openingIndicator * the ObservableSource that, when it emits an item, causes a new buffer to be created * @param closingIndicator * the {@link Function} that is used to produce an ObservableSource for every buffer created. When this * ObservableSource emits an item, the associated buffer is emitted. * @return an Observable that emits buffers, containing items from the source ObservableSource, that are created * and closed when the specified ObservableSources emit items * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <TOpening, TClosing> Observable<List<T>> buffer( ObservableSource<? extends TOpening> openingIndicator, Function<? super TOpening, ? extends ObservableSource<? extends TClosing>> closingIndicator) { return buffer(openingIndicator, closingIndicator, ArrayListSupplier.<T>asCallable()); }
public final <K, V> Flowable<Map<K, Collection<V>>> toMultimap(Function<? super T, ? extends K> keySelector, Function<? super T, ? extends V> valueSelector) { Callable<Map<K, Collection<V>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<V>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory);
/** * Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting * ObservableSource emits buffers that it creates when the specified {@code openingIndicator} ObservableSource emits an * item, and closes when the ObservableSource returned from {@code closingIndicator} emits an item. * <p> * <img width="640" height="470" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer2.png" alt=""> * <dl> * <dt><b>Scheduler:</b></dt> * <dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd> * </dl> * * @param <TOpening> the element type of the buffer-opening ObservableSource * @param <TClosing> the element type of the individual buffer-closing ObservableSources * @param openingIndicator * the ObservableSource that, when it emits an item, causes a new buffer to be created * @param closingIndicator * the {@link Function} that is used to produce an ObservableSource for every buffer created. When this * ObservableSource emits an item, the associated buffer is emitted. * @return an Observable that emits buffers, containing items from the source ObservableSource, that are created * and closed when the specified ObservableSources emit items * @see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a> */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final <TOpening, TClosing> Observable<List<T>> buffer( ObservableSource<? extends TOpening> openingIndicator, Function<? super TOpening, ? extends ObservableSource<? extends TClosing>> closingIndicator) { return buffer(openingIndicator, closingIndicator, ArrayListSupplier.<T>asCallable()); }
public static <T, K, V> Single<Map<K, Collection<V>>> toMultimap(Flowable<T> source, Function<? super T, ? extends K> keySelector, Function<? super T, ? extends V> valueSelector) { Callable<Map<K, Collection<V>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<V>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(source, keySelector, valueSelector, mapSupplier, collectionFactory);