HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_vendor/resolvelib/__pycache__/structs.cpython-310.pyc
o

@%Ne��@sbddlZddlmZGdd�de�ZGdd�dej�ZGdd	�d	e�ZGd
d�de�Zdd
�Z	dS)�N�)�collections_abcc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
DirectedGraphz&A graph structure with directed edges.cCst�|_i|_i|_dS�N)�set�	_vertices�	_forwards�
_backwards��self�r�@/usr/lib/python3/dist-packages/pip/_vendor/resolvelib/structs.py�__init__	s
zDirectedGraph.__init__cC�
t|j�Sr)�iterrr
rrr
�__iter__�
zDirectedGraph.__iter__cCrr)�lenrr
rrr
�__len__rzDirectedGraph.__len__cCs
||jvSr)r�r�keyrrr
�__contains__rzDirectedGraph.__contains__cCsBt�}t|j�|_dd�|j��D�|_dd�|j��D�|_|S)z$Return a shallow copy of this graph.cS�i|]	\}}|t|��qSr�r��.0�k�vrrr
�
<dictcomp>�z&DirectedGraph.copy.<locals>.<dictcomp>cSrrrrrrr
rr)rrrr�itemsr	)r�otherrrr
�copys
zDirectedGraph.copycCs:||jvr	td��|j�|�t�|j|<t�|j|<dS)zAdd a new vertex to the graph.z
vertex existsN)r�
ValueError�addrrr	rrrr
r$s

zDirectedGraph.addcCsT|j�|�|j�|�D]
}|j|�|�q|j�|�D]
}|j|�|�qdS)zCRemove a vertex from the graph, disconnecting all edges from/to it.N)r�remover�popr	)rr�f�trrr
r%'s�zDirectedGraph.removecCs||j|vo
||j|vSr)r	r�rr'r(rrr
�	connected/szDirectedGraph.connectedcCs6||jvr	t|��|j|�|�|j|�|�dS)zgConnect two existing vertices.

        Nothing happens if the vertices are already connected.
        N)r�KeyErrorrr$r	r)rrr
�connect2s
zDirectedGraph.connectccs.�|j��D]\}}|D]}||fVqqdSr)rr )rr'�childrenr(rrr
�
iter_edges<s���zDirectedGraph.iter_edgescC�t|j|�Sr)rrrrrr
�
iter_childrenA�zDirectedGraph.iter_childrencCr/r)rr	rrrr
�iter_parentsDr1zDirectedGraph.iter_parentsN)�__name__�
__module__�__qualname__�__doc__rrrrr"r$r%r*r,r.r0r2rrrr
rs
rc@sJeZdZddd�Zdd�Zdd�ZeZdd	�Zd
d�Zdd
�Z	dd�Z
dS)�IteratorMappingNcCs||_||_|p	i|_dSr)�_mapping�	_accessor�_appends)r�mapping�accessor�appendsrrr
rIszIteratorMapping.__init__cCsd�|j|j|j�S)Nz!IteratorMapping({!r}, {!r}, {!r}))�formatr8r9r:r
rrr
�__repr__Ns
�zIteratorMapping.__repr__cCst|jp|j�Sr)�boolr8r:r
rrr
�__bool__UszIteratorMapping.__bool__cCs||jvp	||jvSr)r8r:rrrr
rZ�zIteratorMapping.__contains__cCsLz|j|}Wntyt|j|�YSwt�|�|�|j�|d��S)Nr)r8r+rr:�	itertools�chainr9�get)rrrrrr
�__getitem__]s�zIteratorMapping.__getitem__cs"�fdd��jD�}t��j|�S)Nc3s�|]
}|�jvr|VqdSr�r8�rrr
rr
�	<genexpr>e��z+IteratorMapping.__iter__.<locals>.<genexpr>)r:rCrDr8�r�morerr
r
rdszIteratorMapping.__iter__cs&t�fdd��jD��}t�j�|S)Nc3s�|]
}|�jvrdVqdS)rNrGrHr
rr
rIirJz*IteratorMapping.__len__.<locals>.<genexpr>)�sumr:rr8rKrr
r
rhszIteratorMapping.__len__r)r3r4r5rr?rA�__nonzero__rrFrrrrrr
r7Hs
r7c@�4eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
S)�_FactoryIterableViewa:Wrap an iterator factory returned by `find_matches()`.

    Calling `iter()` on this class would invoke the underlying iterator
    factory, making it a "collection with ordering" that can be iterated
    through multiple times, but lacks random access methods presented in
    built-in Python sequence types.
    cC�
||_dSr��_factory)r�factoryrrr
rvrz_FactoryIterableView.__init__cCsd�t|�jt|����S�Nz{}({}))r>�typer3�listrSr
rrr
r?ysz_FactoryIterableView.__repr__cCs(z	t|���WdStyYdSw)NFT)�nextrS�
StopIterationr
rrr
rA|s��z_FactoryIterableView.__bool__cCs|��SrrRr
rrr
r�sz_FactoryIterableView.__iter__N�	r3r4r5r6rr?rArNrrrrr
rPmsrPc@rO)�_SequenceIterableViewz�Wrap an iterable returned by find_matches().

    This is essentially just a proxy to the underlying sequence that provides
    the same interface as `_FactoryIterableView`.
    cCrQr)�	_sequence)r�sequencerrr
r�rz_SequenceIterableView.__init__cCsd�t|�j|j�SrU)r>rVr3r\r
rrr
r?�rBz_SequenceIterableView.__repr__cCrr)r@r\r
rrr
rA�rz_SequenceIterableView.__bool__cCrr)rr\r
rrr
r�rz_SequenceIterableView.__iter__NrZrrrr
r[�sr[cCs,t|�rt|�St|tj�st|�}t|�S)zCBuild an iterable view from the value returned by `find_matches()`.)�callablerP�
isinstancer�SequencerWr[)�matchesrrr
�build_iter_view�s
rb)
rC�compatr�objectr�Mappingr7rPr[rbrrrr
�<module>sB%