a *žegcã@sbddlZddlmZGdd„deƒZGdd„dejƒZGdd „d eƒZGd d „d eƒZd d „Z dS)éNé)Úcollections_abcc@speZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)Ú DirectedGraphz&A graph structure with directed edges.cCstƒ|_i|_i|_dS©N)ÚsetÚ _verticesÚ _forwardsÚ _backwards©Úself©r úH/usr/local/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 Ú óz&DirectedGraph.copy..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 )r rÚfÚtr r r r"'s  zDirectedGraph.removecCs||j|vo||j|vSr)r r©r r$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)r r$Úchildrenr%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ÚaccessorÚappendsr r r rIszIteratorMapping.__init__cCsd |j|j|j¡S)Nz!IteratorMapping({!r}, {!r}, {!r}))Úformatr3r4r5r r r r Ú__repr__Ns ýzIteratorMapping.__repr__cCst|jp |jƒSr)Úboolr3r5r r r r Ú__bool__UszIteratorMapping.__bool__cCs||jvp||jvSr)r3r5rr r r rZszIteratorMapping.__contains__cCsLz|j|}Wn ty.t|j|ƒYS0t | |¡|j |d¡¡S)Nr )r3r(rr5Ú itertoolsÚchainr4Úget)r rrr r r Ú __getitem__]s  zIteratorMapping.__getitem__cs"‡fdd„ˆjDƒ}t ˆj|¡S)Nc3s|]}|ˆjvr|VqdSr©r3©rrr r r Ú erz+IteratorMapping.__iter__..)r5r=r>r3©r Úmorer r r rdszIteratorMapping.__iter__cs&t‡fdd„ˆjDƒƒ}tˆjƒ|S)Nc3s|]}|ˆjvrdVqdS)rNrArBr r r rCirz*IteratorMapping.__len__..)Úsumr5rr3rDr r r rhszIteratorMapping.__len__)N) r.r/r0rr:r<Ú __nonzero__rr@rrr r r r r2Hs r2c@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||_d|_dSr)Ú_factoryÚ _iterable)r Úfactoryr r r rvsz_FactoryIterableView.__init__cCsd t|ƒjt|ƒ¡S©Nz{}({}))r9Útyper.Úlistr r r r r:zsz_FactoryIterableView.__repr__cCs*ztt|ƒƒWnty$YdS0dS)NFT)ÚnextrÚ StopIterationr r r r r<}s  z_FactoryIterableView.__bool__cCs,|jdur| ¡n|j}t |¡\|_}|Sr)rJrIr=Útee)r ÚiterableÚcurrentr r r r†sÿz_FactoryIterableView.__iter__N© r.r/r0r1rr:r<rGrr r r r rHms rHc@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)r Úsequencer r r r•sz_SequenceIterableView.__init__cCsd t|ƒj|j¡SrL)r9rMr.rVr r r r r:˜sz_SequenceIterableView.__repr__cCs t|jƒSr)r;rVr r r r r<›sz_SequenceIterableView.__bool__cCs t|jƒSr)rrVr r r r r sz_SequenceIterableView.__iter__NrTr r r r rUŽs rUcCs,t|ƒrt|ƒSt|tjƒs$t|ƒ}t|ƒS)zCBuild an iterable view from the value returned by `find_matches()`.)ÚcallablerHÚ isinstancerÚSequencerNrU)Úmatchesr r r Úbuild_iter_view¤s  r\) r=ÚcompatrÚobjectrÚMappingr2rHrUr\r r r r Ús  B%!