
    i                    ~    S SK Jr  S SKJr  S SKJr  S SKJr  \" S5      r " S S\\   5      r	 " S S	5      r
SS
 jrg)    )annotations)deque)islice)TypeVar_Tc                  @    \ rS rSrSr\SS j5       r\SS j5       rSrg)	_Dependency   z5A class representing a (doubly-ended) queue of items.c                .     U S   $ ! [          a     gf = f)zHead of the dependency.r   N)
IndexErrorselfs    S/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/c3linear.pyhead_Dependency.head   s"    	7N 		s    
c                     [        U SU R                  5       5      $ ! [        [        4 a    [        / SS5      s $ f = f)zgTail of the dependency.

The `islice` object is sufficient for iteration or testing membership (`in`).
   r   )r   __len__
ValueErrorr   r   s    r   tail_Dependency.tail   s?    	$$4<<>22J' 	$"a##	$s    == N)return	_T | None)r   r   )	__name__
__module____qualname____firstlineno____doc__propertyr   r   __static_attributes__r       r   r	   r	      s+    ?  $ $r"   r	   c                      \ rS rSrSrSS jrSS jrSS jrSS jr\	SS j5       r
\	SS j5       r\	SS	 j5       rSS
 jrSrg)_DependencyList(   zA 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.
c                P    U Vs/ s H  n[        U5      PM     snU l        gs  snf )z>Initialize the list.

Parameters:
    *lists: Lists of items.
N)r	   _lists)r   listslsts      r   __init___DependencyList.__init__0   s"     4995C{3'599s   #c                B   ^ [        U4S jU R                   5       5      $ )z9Return True if any linearization's tail contains an item.c              3  B   >#    U  H  nTUR                   ;   v   M     g 7fN)r   ).0r)   items     r   	<genexpr>/_DependencyList.__contains__.<locals>.<genexpr>:   s     ;{4388#{s   )anyr'   )r   r0   s    `r   __contains___DependencyList.__contains__8   s    ;t{{;;;r"   c                H    [        U R                  5      nU(       a  US-
  $ S$ )Nr   r   )lenr'   )r   sizes     r   r   _DependencyList.__len__<   s!    4;;!q(q(r"   c                6    U R                   R                  5       $ r.   )r'   __repr__r   s    r   r;   _DependencyList.__repr__@   s    {{##%%r"   c                X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )zReturn the heads.)r'   r   )r   r)   s     r   heads_DependencyList.headsC   s"     %)KK0KSK000s   'c                    U $ )z3Return self so that `__contains__` could be called.r   r   s    r   tails_DependencyList.tailsH   s	     r"   c                :    [        S U R                   5       5      $ )z0True if all elements of the lists are exhausted.c              3  >   #    U  H  n[        U5      S :H  v   M     g7f)r   N)r7   )r/   xs     r   r1   ,_DependencyList.exhausted.<locals>.<genexpr>P   s     413q6Q;s   )allr'   r   s    r   	exhausted_DependencyList.exhaustedM   s     4444r"   c                    U R                    H.  nU(       d  M  UR                  U:X  d  M  UR                  5         M0     g)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   r0   is      r   remove_DependencyList.removeR   s*     AqQVVt^		 r"   )r'   N)r(   list[_T | None]r   None)r0   r   r   bool)r   int)r   str)r   rO   )r   r$   )r   rQ   )r0   r   r   rP   )r   r   r   r   r   r*   r4   r   r;   r    r>   rA   rH   rM   r!   r   r"   r   r$   r$   (   s\    :<)& 1 1   5 5r"   r$   c                     / n[        U 6 n UR                  (       a  U$ UR                   H?  nU(       d  M  X2R                  ;  d  M  UR	                  U5        UR                  U5          O   [        S5      eMo  )zMerge lists of lists in the order defined by the C3Linear algorithm.

Parameters:
    *lists: Lists of items.

Returns:
    The merged list of items.
zCannot compute C3 linearization)r$   rH   r>   rA   appendrM   r   )r(   resultlinearizationsr   s       r   c3linear_mergerX   ]   sv     F$e,N
##M"((Dt%9%99d#%%d+  ) >?? r"   N)r(   list[_T]r   rY   )
__future__r   collectionsr   	itertoolsr   typingr   r   r	   r$   rX   r   r"   r   <module>r^      s=    #   T]$%) $.2 2j@r"   