src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<T> distinct(Function<? super T, K> keySelector) {
        return distinct(keySelector, Functions.createHashSet());
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <K> Observable<T> distinct(Function<? super T, K> keySelector) {
        return distinct(keySelector, Functions.createHashSet());
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < K > Observable < T > distinct ( Function < ? super T , K > keySelector ) { return distinct ( keySelector , Functions . createHashSet ( ) ) ; }
Returns an Observable that emits all items emitted by the source ObservableSource that are distinct according
to a key selector function and based on {@link Object#equals(Object)} comparison of the objects
returned by the key selector function.
<p>
<img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/distinct.key.png" alt="">
<p>
It is recommended the keys' class {@code K} overrides the default {@code Object.equals()}
and {@link Object#hashCode()} to provide meaningful comparison between the key objects as the default
Java implementation only considers reference equivalence.
<p>
By default, {@code distinct()} uses an internal {@link java.util.HashSet} per Observer to remember
previously seen keys and uses {@link java.util.Set#add(Object)} returning {@code false} as the
indicator for duplicates.
<p>
Note that this internal {@code HashSet} may grow unbounded as keys won't be removed from it by
the operator. Therefore, using very long or infinite upstream (with very distinct keys) may lead
to {@code OutOfMemoryError}.
<p>
Customizing the retention policy can happen only by providing a custom {@link java.util.Collection} implementation
to the {@link #distinct(Function, Callable)} overload.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code distinct} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <K> the key type
@param keySelector
a function that projects an emitted item to a key value that is used to decide whether an item
is distinct from another one or not
@return an Observable that emits those items emitted by the source ObservableSource that have distinct keys
@see <a href="http://reactivex.io/documentation/operators/distinct.html">ReactiveX operators documentation: Distinct</a>
@see #distinct(Function, Callable)
Returns an Observable that emits all items emitted by the source ObservableSource that are distinct according to a key selector function and based on { @link Object#equals ( Object ) } comparison of the objects returned by the key selector function . <p > <img width = 640 height = 310 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / distinct . key . png alt = > <p > It is recommended the keys class { @code K } overrides the default { @code Object . equals () } and { @link Object#hashCode () } to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence . <p > By default { @code distinct () } uses an internal { @link java . util . HashSet } per Observer to remember previously seen keys and uses { @link java . util . Set#add ( Object ) } returning { @code false } as the indicator for duplicates . <p > Note that this internal { @code HashSet } may grow unbounded as keys won t be removed from it by the operator . Therefore using very long or infinite upstream ( with very distinct keys ) may lead to { @code OutOfMemoryError } . <p > Customizing the retention policy can happen only by providing a custom { @link java . util . Collection } implementation to the { @link #distinct ( Function Callable ) } overload . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code distinct } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >