U vi @sddlmZmZmZmZmZmZddlmZm Z mZddl m Z edZ edZ ee e eje dddZGd d d ee Zdeeje e feeje eee gee fd d dZdgZd S))CallableGenericListOptionalTypeVarcast) Observableabctyping)default_comparer_T_TKey)arrayitemcomparercCs(t|D]\}}|||r|SqdSN) enumerate)rrriarN/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_distinct.pyarray_index_of_comparer s  rc@s.eZdZejedddZedddZdS)HashSet)rcCs||_g|_dSN)rset)selfrrrr__init__szHashSet.__init__)valuecCs(t|j||jdk}|r$|j||Sr)rrrappend)rrZ ret_valuerrrpushs z HashSet.pushN)__name__ __module__ __qualname__r Comparerr rr rrrrrsrN) key_mapperrreturncs6|pttjttttttdfdd }|S)N)sourcer&cs2dtjtttjtjdfdd }t|S)a^Returns an observable sequence that contains only distinct elements according to the key_mapper and the comparer. Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. Examples: >>> res = obs = distinct(source) Args: source: Source observable to return distinct items from. Returns: An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. N)observer schedulerr&cs6ttddfdd }j|jj|dS)N)xr&c sftt|}rNz |}Wn2tk rL}z|WYdSd}~XYnX|rb|dSr)rr Exceptionon_errorr on_next)r*keyex)hashsetr%r(rrr->s    z?distinct_..distinct..subscribe..on_next)r))rr subscriber,Z on_completed)r(r)r-) comparer_r%r')r0r(rr18s z.distinct_..distinct..subscribe)N)r Z ObserverBaser rZ SchedulerBaseZDisposableBaser)r'r1r2r%)r'rdistinct%szdistinct_..distinct)rr r$r r rr )r%rr4rr3r distinct_s,r5)NN)r rrrrrrZ reactivexrr Zreactivex.internal.basicr r r r$rrZMapperr5__all__rrrrs"      5