U
    ‰dé  ã                   @   s   G d d„ de ƒZdS )c                   @   sF   e Zd ZdZi Zddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚIndexedListz´
    List with optimised access by value
    Based on Alex Martelli's recipe

    http://code.activestate.com/recipes/52303-the-auxiliary-dictionary-idiom-for-sequences-with-/
    Nc                 C   sF   d| _ i | _|d k	rBd| _ t|ƒD ]\}}|| j|< t | |¡ q"d S )NTF)ÚcleanÚ_dictÚ	enumerateÚlistÚappend)ÚselfÚiterableÚidxÚval© r   ú?/tmp/pip-unpacked-wheel-rwywncvq/openpyxl/utils/indexed_list.pyÚ__init__   s    
zIndexedList.__init__c                 C   s:   i | _ d}| D ] }|| j kr|| j |< |d7 }qd| _d S )Né    é   T)r   r   )r   r	   Úvaluer   r   r   Ú_rebuild_dict   s    


zIndexedList._rebuild_dictc                 C   s   | j s|  ¡  || jkS ©N)r   r   r   ©r   r   r   r   r   Ú__contains__    s    zIndexedList.__contains__c                 C   s   || kr| j | S t‚d S r   )r   Ú
ValueErrorr   r   r   r   Úindex%   s    
zIndexedList.indexc                 C   s(   || j kr$t| ƒ| j |< t | |¡ d S r   )r   Úlenr   r   r   r   r   r   r   *   s    
zIndexedList.appendc                 C   s   |   |¡ | j| S r   )r   r   r   r   r   r   Úadd/   s    
zIndexedList.add)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r      s   
		r   N)r   r   r   r   r   r   Ú<module>   ó    