
    -h                        d dl mZ d dlmZ d dlmZ d dlmZ  ed          Z G d dee                   Z	 G d d	          Z
ddZdS )    )annotations)deque)islice)TypeVar_Tc                  B    e Zd ZdZedd            Zed	d            ZdS )
_Dependencyz5A class representing a (doubly-ended) queue of items.return	_T | Nonec                6    	 | d         S # t           $ r Y dS w xY w)zHead of the dependency.r   N)
IndexErrorselfs    M/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/_griffe/c3linear.pyheadz_Dependency.head   s2    	7N 	 	 	44	s   
 
r   c                    	 t          | d|                                           S # t          t          f$ r t          g dd          cY S w xY w)zwTail of the dependency.

        The `islice` object is sufficient for iteration or testing membership (`in`).
           r   )r   __len__
ValueErrorr   r   s    r   tailz_Dependency.tail   sY    	$$4<<>>222J' 	$ 	$ 	$"a#####	$s   "% "A
	A
N)r
   r   )r
   r   )__name__
__module____qualname____doc__propertyr   r        r   r	   r	      sX        ??   X $ $ $ X$ $ $r   r	   c                      e Zd ZdZddZdd
ZddZddZedd            Z	edd            Z
edd            ZddZdS )_DependencyListzA class representing a list of linearizations (dependencies).

    The last element of DependencyList is a list of parents.
    It's needed  to the merge process preserves the local
    precedence order of direct parent classes.
    listslist[_T | None]r
   Nonec                (    d |D             | _         dS )zVInitialize the list.

        Parameters:
            *lists: Lists of items.
        c                ,    g | ]}t          |          S r   )r	   .0lsts     r   
<listcomp>z,_DependencyList.__init__.<locals>.<listcomp>6   s     999C{3''999r   N_lists)r   r    s     r   __init__z_DependencyList.__init__0   s     :95999r   itemr   boolc                D    t          fd| j        D                       S )z9Return True if any linearization's tail contains an item.c              3  *   K   | ]}|j         v V  d S N)r   )r&   r'   r,   s     r   	<genexpr>z/_DependencyList.__contains__.<locals>.<genexpr>:   s*      ;;438#;;;;;;r   )anyr*   )r   r,   s    `r   __contains__z_DependencyList.__contains__8   s(    ;;;;t{;;;;;;r   intc                <    t          | j                  }|r|dz
  ndS )Nr   r   )lenr*   )r   sizes     r   r   z_DependencyList.__len__<   s$    4;!(qq(r   strc                4    | j                                         S r0   )r*   __repr__r   s    r   r:   z_DependencyList.__repr__@   s    {##%%%r   c                $    d | j         D             S )zReturn the heads.c                    g | ]	}|j         
S r   )r   r%   s     r   r(   z)_DependencyList.heads.<locals>.<listcomp>F   s    000S000r   r)   r   s    r   headsz_DependencyList.headsC   s     10DK0000r   c                    | S )z3Return self so that `__contains__` could be called.r   r   s    r   tailsz_DependencyList.tailsH   s	     r   c                >    t          d | j        D                       S )z0True if all elements of the lists are exhausted.c              3  <   K   | ]}t          |          d k    V  dS )r   N)r6   )r&   xs     r   r1   z,_DependencyList.exhausted.<locals>.<genexpr>P   s,      4413q66Q;444444r   )allr*   r   s    r   	exhaustedz_DependencyList.exhaustedM   s#     44444444r   r   c                \    | j         D ]#}|r|j        |k    r|                                 $dS )zRemove an item from the lists.

        Once an item removed from heads, the leftmost elements of the tails
        get promoted to become the new heads.
        N)r*   r   popleft)r   r,   is      r   removez_DependencyList.removeR   s?      	 	A QVt^^			 	r   N)r    r!   r
   r"   )r,   r   r
   r-   )r
   r4   )r
   r8   )r
   r!   )r
   r   )r
   r-   )r,   r   r
   r"   )r   r   r   r   r+   r3   r   r:   r   r=   r?   rD   rH   r   r   r   r   r   (   s         : : : :< < < <) ) ) )& & & & 1 1 1 X1    X 5 5 5 X5     r   r   r    list[_T]r
   c                     g }t          |  }	 |j        r|S |j        D ]9}|r5||j        vr,|                    |           |                    |            n:t          d          Z)zMerge lists of lists in the order defined by the C3Linear algorithm.

    Parameters:
        *lists: Lists of items.

    Returns:
        The merged list of items.
    TzCannot compute C3 linearization)r   rD   r=   r?   appendrH   r   )r    resultlinearizationsr   s       r   c3linear_mergerN   ]   s     F$e,N@# 	M"( 
	@ 
	@D ^%999d###%%d+++  >???@r   N)r    rI   r
   rI   )
__future__r   collectionsr   	itertoolsr   typingr   r   r	   r   rN   r   r   r   <module>rS      s    # " " " " "                  WT]]$ $ $ $ $%) $ $ $.2 2 2 2 2 2 2 2j@ @ @ @ @ @r   