@CheckReturnValue
    @NonNull
    @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K, V> Single<Map<K, Collection<V>>> toMultimap(
            final Function<? super T, ? extends K> keySelector,
            final Function<? super T, ? extends V> valueSelector,
            final Callable<? extends Map<K, Collection<V>>> mapSupplier,
            final Function<? super K, ? extends Collection<? super V>> collectionFactory) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
        ObjectHelper.requireNonNull(mapSupplier, "mapSupplier is null");
        ObjectHelper.requireNonNull(collectionFactory, "collectionFactory is null");
        return collect(mapSupplier, Functions.toMultimapKeyValueSelector(keySelector, valueSelector, collectionFactory));
    }
@CheckReturnValue
    @NonNull
    @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K, V> Single<Map<K, Collection<V>>> toMultimap(
            final Function<? super T, ? extends K> keySelector,
            final Function<? super T, ? extends V> valueSelector,
            final Callable<? extends Map<K, Collection<V>>> mapSupplier,
            final Function<? super K, ? extends Collection<? super V>> collectionFactory) {
        ObjectHelper.requireNonNull(keySelector, "keySelector is null");
        ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
        ObjectHelper.requireNonNull(mapSupplier, "mapSupplier is null");
        ObjectHelper.requireNonNull(collectionFactory, "collectionFactory is null");
        return collect(mapSupplier, Functions.toMultimapKeyValueSelector(keySelector, valueSelector, collectionFactory));
    }
@ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . UNBOUNDED_IN ) @ SchedulerSupport ( SchedulerSupport . NONE ) public final < K , V > Single < Map < K , Collection < V > > > toMultimap ( final Function < ? super T , ? extends K > keySelector , final Function < ? super T , ? extends V > valueSelector , final Callable < ? extends Map < K , Collection < V > > > mapSupplier , final Function < ? super K , ? extends Collection < ? super V > > collectionFactory ) { ObjectHelper . requireNonNull ( keySelector , "keySelector is null" ) ; ObjectHelper . requireNonNull ( valueSelector , "valueSelector is null" ) ; ObjectHelper . requireNonNull ( mapSupplier , "mapSupplier is null" ) ; ObjectHelper . requireNonNull ( collectionFactory , "collectionFactory is null" ) ; return collect ( mapSupplier , Functions . toMultimapKeyValueSelector ( keySelector , valueSelector , collectionFactory ) ) ; }
Returns a Single that emits a single Map, returned by a specified {@code mapFactory} function, that
contains a custom collection of values, extracted by a specified {@code valueSelector} function from
items emitted by the finite source Publisher, and keyed by the {@code keySelector} function.
<p>
<img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toMultiMap.png" alt="">
<p>
Note that this operator requires the upstream to signal {@code onComplete} for the accumulated map to
be emitted. Sources that are infinite and never complete will never emit anything through this
operator and an infinite source may lead to a fatal {@code OutOfMemoryError}.
<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 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 the key in the Map
@param valueSelector
the function that extracts a value from the source items to be used as the value in the Map
@param mapSupplier
the function that returns a Map instance to be used
@param collectionFactory
the function that returns a Collection instance for a particular key to be used in the Map
@return a Single that emits a single item: a Map that contains the collection of mapped items from
the source Publisher
@see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
Returns a Single that emits a single Map returned by a specified { @code mapFactory } function that contains a custom collection of values extracted by a specified { @code valueSelector } function from items emitted by the finite source Publisher and keyed by the { @code keySelector } function . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / toMultiMap . png alt = > <p > Note that this operator requires the upstream to signal { @code onComplete } for the accumulated map to be emitted . Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal { @code OutOfMemoryError } . <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 toMultimap } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >