U
vi5 @ s d dl mZmZmZmZ d dlmZmZ d dlm Z m
Z
d dlmZm
Z
edZedZdee
eef eee eee gee f dd d
Zd
gZdS ) )CallableOptionalTypeVarcast)
Observableabc)default_compareridentity)ComparerMapper_T_TKeyN)
key_mappercomparerreturnc sB | pt ttgtf t|pt tt tt d fdd}|S )N)sourcer c s2 dt jt tt j t jd fdd
}t|S )ay Returns an observable sequence that contains only distinct
contiguous elements according to the key_mapper and the
comparer.
Examples:
>>> op = distinct_until_changed();
>>> op = distinct_until_changed(lambda x: x.id)
>>> op = distinct_until_changed(lambda x: x.id, lambda x, y: x == y)
Args:
key_mapper: [Optional] A function to compute the comparison
key for each element. If not provided, it projects the
value.
comparer: [Optional] Equality comparer for computed key
values. If not provided, defaults to an equality
comparer function.
Returns:
An observable sequence only containing the distinct
contiguous elements, based on a computed key value, from
the source sequence.
N)observer schedulerr c s@ dt td td d fdd}j|jj|dS )NF)valuer c
s d}z| }W n2 t k
rB } z| W Y d S d }~X Y nX rz |}W n2 t k
r } z| W Y d S d }~X Y nX r|sd|| d S )NFT) Exceptionon_erroron_next)r Zcomparer_equalskey exception) comparer_current_keyhas_current_keykey_mapper_r Z/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_distinctuntilchanged.pyr 2 s
z[distinct_until_changed_.