/** * 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 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 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 a Single that emits a single HashMap containing all items emitted by the source ObservableSource, * mapped by the keys returned by a specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMap.2.png" alt=""> * <p> * If more than one source item maps to the same key, the HashMap will contain the latest of those items. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMap} 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 a source item to be used in the HashMap * @return a Single that emits a single item: a HashMap containing the mapped items 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, T>> toMap(final Function<? super T, ? extends K> keySelector) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector)); }
/** * Returns a Single that emits a single HashMap containing all items emitted by the source ObservableSource, * mapped by the keys returned by a specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMap.2.png" alt=""> * <p> * If more than one source item maps to the same key, the HashMap will contain the latest of those items. * <dl> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMap} 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 a source item to be used in the HashMap * @return a Single that emits a single item: a HashMap containing the mapped items 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, T>> toMap(final Function<? super T, ? extends K> keySelector) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector)); }
/** * 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); }
@SchedulerSupport(SchedulerSupport.NONE) 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);
@SchedulerSupport(SchedulerSupport.NONE) 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);
/** * Returns a Single that emits a single HashMap containing all items emitted by the source Publisher, * mapped by the keys returned by a specified {@code keySelector} function. * <p> * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMap.png" alt=""> * <p> * If more than one source item maps to the same key, the HashMap will contain the latest of those items. * <dl> * <dt><b>Backpressure:</b></dt> * <dd>The operator honors backpressure from downstream and consumes the source {@code Publisher} in an * unbounded manner (i.e., without applying backpressure to it).</dd> * <dt><b>Scheduler:</b></dt> * <dd>{@code toMap} 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 a source item to be used in the HashMap * @return a Single that emits a single item: a HashMap containing the mapped items from the source * Publisher * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) public final <K> Flowable<Map<K, T>> toMap(final Function<? super T, ? extends K> keySelector) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector)); }
/** * Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the * source Publisher 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.png" alt=""> * <dl> * <dt><b>Backpressure:</b></dt> * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything.</dd> * <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 Publisher * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) public final <K> Flowable<Map<K, Collection<T>>> toMultimap(Function<? super T, ? extends K> keySelector) { Function<T, T> valueSelector = Functions.identity(); Callable<Map<K, Collection<T>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<T>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory); }
ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(valueSelector, "valueSelector is null"); return collect(HashMapSupplier.<K, V>asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
/** * Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the * source Publisher 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.png" alt=""> * <dl> * <dt><b>Backpressure:</b></dt> * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything.</dd> * <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 <T> the source value type * @param source the source Flowable instance * @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 Publisher * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> */ @CheckReturnValue @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) public static <T, K> Single<Map<K, Collection<T>>> toMultimap(Flowable<T> source, Function<? super T, ? extends K> keySelector) { Function<T, T> valueSelector = Functions.identity(); Callable<Map<K, Collection<T>>> mapSupplier = HashMapSupplier.asCallable(); Function<K, List<T>> collectionFactory = ArrayListSupplier.asFunction(); return toMultimap(source, keySelector, valueSelector, mapSupplier, collectionFactory); }
public static <T, K> Single<Map<K, T>> toMap(Flowable<T> source, final Function<? super T, ? extends K> keySelector) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); return collect(source, HashMapSupplier.<K, T>asCallable(), Functions.toMapKeySelector(keySelector));
ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(valueSelector, "valueSelector is null"); return collect(HashMapSupplier.<K, V>asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(valueSelector, "valueSelector is null"); return collect(source, HashMapSupplier.<K, V>asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(valueSelector, "valueSelector is null"); return collect(HashMapSupplier.<K, V>asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));