U
    ®ª/e‡  ã                   @  sL   d dl mZ d dlmZmZ d dlmZ d dlmZ G dd„ dee ƒZ	dS )é    )Úannotations)ÚIterableÚIterator)Ú
MutableSet)ÚTc                   @  sº   e Zd ZU dZded< dZd&dddœd	d
„Zdddœdd„Zddœdd„Zddœdd„Z	dddœdd„Z
dddœdd„Zdddœdd„Zddœdd „Zddœd!d"„ZeZddœd#d$„Zd%S )'ÚInsertionSortedSetzéA set-like that retains insertion order, like a dict. Thread-safe.

    Equality does not compare order or class, but only compares against the contents of
    any other set-like, coherently with dict and the AbstractSet design.
    zdict[T, None]Ú_d©r   © zIterable[T]ÚNone)ÚotherÚreturnc                 C  s   t  |¡| _d S ©N)ÚdictÚfromkeysr   )Úselfr   r
   r
   ú./tmp/pip-unpacked-wheel-z3s6s24u/zict/utils.pyÚ__init__   s    zInsertionSortedSet.__init__ÚobjectÚbool)Úitemr   c                 C  s
   || j kS r   r	   )r   r   r
   r
   r   Ú__contains__   s    zInsertionSortedSet.__contains__zIterator[T])r   c                 C  s
   t | jƒS r   )Úiterr   ©r   r
   r
   r   Ú__iter__   s    zInsertionSortedSet.__iter__Úintc                 C  s
   t | jƒS r   )Úlenr   r   r
   r
   r   Ú__len__   s    zInsertionSortedSet.__len__r   )Úvaluer   c                 C  s   d| j |< dS )zoAdd element to the set. If the element is already in the set, retain original
        insertion order.
        Nr	   ©r   r   r
   r
   r   Úadd   s    zInsertionSortedSet.addc                 C  s&   z| j |= W n tk
r    Y nX d S r   )r   ÚKeyErrorr   r
   r
   r   Údiscard%   s    zInsertionSortedSet.discardc                 C  s   | j |= d S r   r	   r   r
   r
   r   Úremove,   s    zInsertionSortedSet.removec              	   C  sZ   zt t| jƒƒ}| j|= |W S  tk
r8   tdƒ‚Y q  ttfk
rR   Y q Y q X q dS )z(Pop the oldest-inserted key from the setzpop from an empty setN)Únextr   r   ÚStopIterationr!   ÚRuntimeErrorr   r
   r
   r   Úpopleft/   s    zInsertionSortedSet.popleftc                 C  s   | j  ¡ d S )z(Pop the latest-inserted key from the setr   )r   Úpopitemr   r
   r
   r   Úpopright<   s    zInsertionSortedSet.poprightc                 C  s   | j  ¡  d S r   )r   Úclearr   r
   r
   r   r*   B   s    zInsertionSortedSet.clearN)r
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Ú	__slots__r   r   r   r   r    r"   r#   r'   r)   Úpopr*   r
   r
   r
   r   r   	   s   
r   N)
Ú
__future__r   Úcollections.abcr   r   Útypingr   Zzict.commonr   r   r
   r
   r
   r   Ú<module>   s   