î
æ^Q\é  ã               @   s   Gd  d „  d e  ƒ Z d S)c               @   sg   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   sh   d |  _  i  |  _ | d  k	 rd d |  _  x: t | ƒ D]) \ } } | |  j | <t j |  | ƒ q4 Wn  d  S)NTF)ÚcleanÚ_dictÚ	enumerateÚlistÚappend)ÚselfÚiterableÚidxÚval© r   úP/var/www/dbchiro/venv/lib/python3.4/site-packages/openpyxl/utils/indexed_list.pyÚ__init__   s    			zIndexedList.__init__c             C   sV   i  |  _  d } x7 |  D]/ } | |  j  k r | |  j  | <| d 7} q q Wd |  _ d  S)Né    é   T)r   r   )r   r	   Úvaluer   r   r   Ú_rebuild_dict   s    	zIndexedList._rebuild_dictc             C   s#   |  j  s |  j ƒ  n  | |  j k S)N)r   r   r   )r   r   r   r   r   Ú__contains__    s    	zIndexedList.__contains__c             C   s!   | |  k r |  j  | St ‚ d  S)N)r   Ú
ValueError)r   r   r   r   r   Úindex%   s    zIndexedList.indexc             C   s9   | |  j  k r5 t |  ƒ |  j  | <t j |  | ƒ n  d  S)N)r   Úlenr   r   )r   r   r   r   r   r   *   s    zIndexedList.appendc             C   s   |  j  | ƒ |  j | S)N)r   r   )r   r   r   r   r   Úadd/   s    zIndexedList.add)Ú__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>   s    