Current File : //lib/python3.9/site-packages/pip/_vendor/resolvelib/__pycache__/structs.cpython-39.pyc
a

[��f��@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�B/usr/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py�__init__	szDirectedGraph.__init__cCs
t|j�Sr)�iterrr
rrr
�__iter__szDirectedGraph.__iter__cCs
t|j�Sr)�lenrr
rrr
�__len__szDirectedGraph.__len__cCs
||jvSr)r�r�keyrrr
�__contains__szDirectedGraph.__contains__cCsBt�}t|j�|_dd�|j��D�|_dd�|j��D�|_|S)z$Return a shallow copy of this graph.cSsi|]\}}|t|��qSr�r��.0�k�vrrr
�
<dictcomp>�z&DirectedGraph.copy.<locals>.<dictcomp>cSsi|]\}}|t|��qSrrrrrr
rr)rrrr�itemsr	)r�otherrrr
�copys
zDirectedGraph.copycCs:||jvrtd��|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|�|�q:dS)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||jvrt|��|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]}||fVqq
dSr)rr)rr$Zchildrenr%rrr
�
iter_edges<szDirectedGraph.iter_edgescCst|j|�Sr)rrrrrr
�
iter_childrenAszDirectedGraph.iter_childrencCst|j|�Sr)rr	rrrr
�iter_parentsDszDirectedGraph.iter_parentsN)�__name__�
__module__�__qualname__�__doc__rrrrrr!r"r'r)r*r+r,rrrr
rs
rc@sJeZdZddd�Zdd�Zdd�ZeZdd	�Zd
d�Zdd
�Z	dd�Z
dS)�IteratorMappingNcCs||_||_|pi|_dSr)�_mapping�	_accessor�_appends)r�mapping�accessorZappendsrrr
rIszIteratorMapping.__init__cCsd�|j|j|j�S)Nz!IteratorMapping({!r}, {!r}, {!r}))�formatr2r3r4r
rrr
�__repr__Ns
�zIteratorMapping.__repr__cCst|jp|j�Sr)�boolr2r4r
rrr
�__bool__UszIteratorMapping.__bool__cCs||jvp||jvSr)r2r4rrrr
rZszIteratorMapping.__contains__cCsLz|j|}Wn ty.t|j|�YS0t�|�|�|j�|d��S)Nr)r2r(rr4�	itertools�chainr3�get)rrrrrr
�__getitem__]s
zIteratorMapping.__getitem__cs"�fdd��jD�}t��j|�S)Nc3s|]}|�jvr|VqdSr�r2�rrr
rr
�	<genexpr>erz+IteratorMapping.__iter__.<locals>.<genexpr>)r4r;r<r2�rZmorerr
r
rdszIteratorMapping.__iter__cs&t�fdd��jD��}t�j�|S)Nc3s|]}|�jvrdVqdS)rNr?r@r
rr
rAirz*IteratorMapping.__len__.<locals>.<genexpr>)�sumr4rr2rBrr
r
rhszIteratorMapping.__len__)N)r-r.r/rr8r:�__nonzero__rr>rrrrrr
r1Hs
r1c@s4eZdZdZdd�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.
    cCs
||_dSr��_factory)r�factoryrrr
rvsz_FactoryIterableView.__init__cCsd�t|�jt|����S�Nz{}({}))r7�typer-�listrGr
rrr
r8ysz_FactoryIterableView.__repr__cCs*zt|���Wnty$YdS0dS)NFT)�nextrG�
StopIterationr
rrr
r:|s
z_FactoryIterableView.__bool__cCs|��SrrFr
rrr
r�sz_FactoryIterableView.__iter__N�	r-r.r/r0rr8r:rDrrrrr
rEmsrEc@s4eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
S)�_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`.
    cCs
||_dSr)�	_sequence)rZsequencerrr
r�sz_SequenceIterableView.__init__cCsd�t|�j|j�SrI)r7rJr-rPr
rrr
r8�sz_SequenceIterableView.__repr__cCs
t|j�Sr)r9rPr
rrr
r:�sz_SequenceIterableView.__bool__cCs
t|j�Sr)rrPr
rrr
r�sz_SequenceIterableView.__iter__NrNrrrr
rO�srOcCs,t|�rt|�St|tj�s$t|�}t|�S)zCBuild an iterable view from the value returned by `find_matches()`.)�callablerE�
isinstancer�SequencerKrO)�matchesrrr
�build_iter_view�s
rU)
r;�compatr�objectr�Mappingr1rErOrUrrrr
�<module>sB%