B
    q\                 @   s   d Z G dd deZdS )z5
A module containing specialized collection classes.
c                   sd   e Zd ZdZg f fdd	Zdd Zdd Z fdd	Z fd
dZ fddZ	 fddZ
  ZS )HomogeneousListz
    A subclass of list that contains only elements of a given type or
    types.  If an item that is not of the specified type is added to
    the list, a `TypeError` is raised.
    c                s   || _ t   | | dS )z
        Parameters
        ----------
        types : sequence of types
            The types to accept.

        values : sequence, optional
            An initial set of values.
        N)_typessuper__init__extend)selftypesvalues)	__class__ 8lib/python3.7/site-packages/astropy/utils/collections.pyr      s    

zHomogeneousList.__init__c             C   s    t || jstd| jd S )Nz7homogeneous list must contain only objects of type '{}')
isinstancer   	TypeErrorformat)r   xr
   r
   r   _assert   s    zHomogeneousList._assertc             C   s   |  | | S )N)r   )r   otherr
   r
   r   __iadd__!   s    
zHomogeneousList.__iadd__c                sD   t |tr,t|}x"|D ]}| | qW n
| | t ||S )N)r   slicelistr   r   __setitem__)r   idxvalueitem)r	   r
   r   r   %   s    


zHomogeneousList.__setitem__c                s   |  | t |S )N)r   r   append)r   r   )r	   r
   r   r   .   s    
zHomogeneousList.appendc                s   |  | t ||S )N)r   r   insert)r   ir   )r	   r
   r   r   2   s    
zHomogeneousList.insertc                s(   x"|D ]}|  | t | qW d S )N)r   r   r   )r   r   r   )r	   r
   r   r   6   s    

zHomogeneousList.extend)__name__
__module____qualname____doc__r   r   r   r   r   r   r   __classcell__r
   r
   )r	   r   r      s   	r   N)r   r   r   r
   r
   r
   r   <module>   s   