src/main/java/io/reactivex/Observable.java
@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);
    }
@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);
    }
@ 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 that contains an ArrayList of items emitted by the
finite 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="">
<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>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>
Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the finite 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 = > <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 > Scheduler : < / b > < / dt > <dd > { @code toMultimap } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >