n9eddlmZmZddlZddlmZmZddlmZeddZ Gdd ee Z eje eje e eZ d d Z d Zy) )SetHashableN)TypeVarGeneric)pmapT_coT) covariantceZdZdZdZfdZdZdZdZdZ dZ d Z d Z e dd Zd Zd ZdZdZGddeZdZdZej0Zej2Zej4Zej6Zej8Zej:Zej<Zej>Zej@Z ejBZ!eZ"eZ#eZ$eZ%e Z&e!Z'ejPZ(xZ)S)PSeta! Persistent set implementation. Built on top of the persistent map. The set supports all operations in the Set protocol and is Hashable. Do not instantiate directly, instead use the factory functions :py:func:`s` or :py:func:`pset` to create an instance. Random access and insert is log32(n) where n is the size of the set. Some examples: >>> s = pset([1, 2, 3, 1]) >>> s2 = s.add(4) >>> s3 = s2.remove(2) >>> s pset([1, 2, 3]) >>> s2 pset([1, 2, 3, 4]) >>> s3 pset([1, 3, 4]) )_map __weakref__c<tt| |}||_|SN)superr __new__r )clsmself __class__s 2/usr/lib/python3/dist-packages/pyrsistent/_pset.pyrz PSet.__new__!s T3',  c||jvSr)r relements r __contains__zPSet.__contains__&s$))##rc,t|jSr)iterr rs r__iter__z PSet.__iter__)DIIrc,t|jSr)lenr rs r__len__z PSet.__len__,s499~rc|sdtt|zSdjtt|ddS)Npz pset([{0}]))strsetformatrs r__repr__z PSet.__repr__/s8SY' '##CD N1R$899rc"|jSr)r+rs r__str__z PSet.__str__5s}}rc,t|jSr)hashr rs r__hash__z PSet.__hash__8r rc&tt|ffSr)psetlistrs r __reduce__zPSet.__reduce__;sd4j]""rcNtttd|D|S)Nc3$K|]}|df yw)TN).0ks r z&PSet._from_iterable..As4Aq$i4spre_size)r rdict)ritr<s r_from_iterablezPSet._from_iterable?sD444xHIIrc\|jj|jS)z~ Return a new PSet with element added >>> s1 = s(1, 2) >>> s1.add(3) pset([1, 2, 3]) evolveradd persistentrs rrCzPSet.addCs$||~!!'*5577rcr|j}|D]}|j||jS)z Return a new PSet with elements in iterable added >>> s1 = s(1, 2) >>> s1.update([3, 4, 4]) pset([1, 2, 3, 4]) rA)riterableers rupdatez PSet.updateMs7 LLN G EE'N ||~rc||jvr-|jj|jSt dt |z)z Return a new PSet with element removed. Raises KeyError if element is not present. >>> s1 = s(1, 2) >>> s1.remove(2) pset([1]) z Element '%s' not present in PSet)r rBremoverDKeyErrorreprrs rrJz PSet.remove[sE dii <<>((1<<> >9DMIJJrc|||jvr-|jj|jS|S)zc Return a new PSet with element removed. Returns itself if element is not present. )r rBrJrDrs rdiscardz PSet.discardhs5 dii <<>((1<<> > rc4eZdZdZdZdZdZdZdZdZ y) PSet._Evolver)_original_pset _pmap_evolvercP||_|jj|_yr)rQr rBrR)r original_psets r__init__zPSet._Evolver.__init__ts!"/D !.!3!3!;!;!=D rc$d|j|<|S)NTrRrs rrCzPSet._Evolver.addxs*.D  w 'Krc |j|=|SrrWrs rrJzPSet._Evolver.remove|s""7+Krc6|jjSr)rRis_dirtyrs rrZzPSet._Evolver.is_dirtys%%..0 0rc|js |jSt|jj Sr)rZrQr rRrDrs rrDzPSet._Evolver.persistents1==?+++**5578 8rc,t|jSr)r"rRrs rr#zPSet._Evolver.__len__st))* *rN) __name__ __module__ __qualname__ __slots__rUrCrJrZrDr#r7rr_EvolverrPqs%7  >   1 9  +rrac|Srr7rs rcopyz PSet.copys rc,tj|S)a! Create a new evolver for this pset. For a discussion on evolvers in general see the documentation for the pvector evolver. Create the evolver and perform various mutating updates to it: >>> s1 = s(1, 2, 3) >>> e = s1.evolver() >>> _ = e.add(4) >>> len(e) 4 >>> _ = e.remove(1) The underlying pset remains the same: >>> s1 pset([1, 2, 3]) The changes are kept in the evolver. An updated pmap can be created using the persistent() function on the evolver. >>> s2 = e.persistent() >>> s2 pset([2, 3, 4]) The new pset will share data with the original pset in the same way that would have been done if only using operations on the pset. )r rars rrBz PSet.evolvers:}}T""r))*r]r^r___doc__r`rrrr#r+r-r0r4 classmethodr?rCrHrJrNobjectrarcrBr__le____lt____gt____ge____eq____ne____and____or____sub____xor__issubset issupersetunion intersection differencesymmetric_difference isdisjoint __classcell__)rs@rr r s*(I $: #JJ8  K+6+6#FZZF ZZF ZZF ZZF ZZF ZZFkkG ZZFkkGkkGHJ ELJ"Jrr c@|stStj||S)z Creates a persistent set from iterable. Optionally takes a sizing parameter equivalent to that used for :py:func:`pmap`. >>> s1 = pset([1, 2, 3, 2]) >>> s1 pset([1, 2, 3]) r;) _EMPTY_PSETr r?)rFr<s rr2r2s#    x(  ;;rct|S)z Create a persistent set. Takes an arbitrary number of arguments to insert into the new set. >>> s1 = s(1, 2, 3, 2) >>> s1 pset([1, 2, 3]) )r2)elementss rsrs >r)r7re)collections.abcrrsystypingrrpyrsistent._pmaprrr registerr|r2rr7rrrse) #!v&| 74=| |  T$46l  < r