JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrB +[b@sddlmZmZmZmZddlmZddlmZddZ Gddde Z e e e e e e e e d d Z d d Ze eZd S)) ContainerIterableSizedHashable)reduce)pmapcCs||||ddS)Nrr)setget)Zcounterselementr C/opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/_pbag.py_add_to_counterssrc@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZeZeZeZddZddZddZdd Zd!d"Zd#S)$PBaga A persistent bag/multiset type. Requires elements to be hashable, and allows duplicates, but has no ordering. Bags are hashable. Do not instantiate directly, instead use the factory functions :py:func:`b` or :py:func:`pbag` to create an instance. Some examples: >>> s = pbag([1, 2, 3, 1]) >>> s2 = s.add(4) >>> s3 = s2.remove(1) >>> s pbag([1, 1, 2, 3]) >>> s2 pbag([1, 1, 2, 3, 4]) >>> s3 pbag([1, 2, 3, 4]) )_counts __weakref__cCs ||_dS)N)r)selfcountsr r r __init__#sz PBag.__init__cCstt|j|S)z Add an element to the bag. >>> s = pbag([1]) >>> s2 = s.add(1) >>> s3 = s.add(2) >>> s2 pbag([1, 1]) >>> s3 pbag([1, 2]) )rrr)rr r r r add&s zPBag.addcCs|rttt||jS|S)z Update bag with all elements in iterable. >>> s = pbag([1]) >>> s.update([1, 2]) pbag([1, 1, 2]) )rrrr)riterabler r r update4sz PBag.updatecCsP||jkrt|n4|j|dkr0|j|}n|j||j|d}t|S)z Remove an element from the bag. >>> s = pbag([1, 1, 2]) >>> s2 = s.remove(1) >>> s3 = s.remove(2) >>> s2 pbag([1, 2]) >>> s3 pbag([1, 1]) r)rKeyErrorremover r)rr Znewcr r r rAs  z PBag.removecCs|j|dS)z Return the number of times an element appears. >>> pbag([]).count('non-existent') 0 >>> pbag([1, 1, 2]).count(1) 2 r)rr )rr r r r countUs z PBag.countcCst|jS)ze Return the length including duplicates. >>> len(pbag([1, 1, 2])) 3 )sumrZ itervalues)rr r r __len__asz PBag.__len__ccs4x.|jD] \}}xt|D] }|VqWq WdS)z Return an iterator of all elements, including duplicates. >>> list(pbag([1, 1, 2])) [1, 1, 2] >>> list(pbag([1, 2])) [1, 2] N)r iteritemsrange)reltrir r r __iter__js z PBag.__iter__cCs ||jkS)z Check if an element is in the bag. >>> 1 in pbag([1, 1, 2]) True >>> 0 in pbag([1, 2]) False )r)rrr r r __contains__ws zPBag.__contains__cCsdt|S)Nz pbag({0}))formatlist)rr r r __repr__sz PBag.__repr__cCs t|tk rtd|j|jkS)z Check if two bags are equivalent, honoring the number of duplicates, and ignoring insertion order. >>> pbag([1, 1, 2]) == pbag([1, 2]) False >>> pbag([2, 1, 0]) == pbag([0, 1, 2]) True z Can only compare PBag with PBags)typer TypeErrorr)rotherr r r __eq__s z PBag.__eq__cCs tddS)NzPBags are not orderable)r')rr(r r r __lt__sz PBag.__lt__cCsNt|tstS|j}x(|jD]\}}|||||<q$Wt|S)z Combine elements from two PBags. >>> pbag([1, 2, 2]) + pbag([2, 3, 3]) pbag([1, 2, 2, 2, 3, 3]) ) isinstancerNotImplementedrevolverrr persistent)rr(resultelem other_countr r r __add__s   z PBag.__add__cCsnt|tstS|j}xH|jD]:\}}|||}|dkrL|||<q$||kr$||q$Wt|S)z Remove elements from one PBag that are present in another. >>> pbag([1, 2, 2, 2, 3]) - pbag([2, 3, 3, 4]) pbag([1, 2, 2]) r) r+rr,rr-rrrr.)rr(r/r0r1newcountr r r __sub__s   z PBag.__sub__cCsXt|tstS|j}x2|jD]$\}}||}t||}|||<q$Wt|S)z Union: Keep elements that are present in either of two PBags. >>> pbag([1, 2, 2, 2]) | pbag([2, 3, 3]) pbag([1, 2, 2, 2, 3, 3]) ) r+rr,rr-rrmaxr.)rr(r/r0r1rr3r r r __or__s     z PBag.__or__cCs\t|tstSt}x6|jD](\}}t|||}|dkr$|||<q$Wt| S)z Intersection: Only keep elements that are present in both PBags. >>> pbag([1, 2, 2, 2]) & pbag([2, 3, 3]) pbag([2]) r) r+rr,rr-rrminrr.)rr(r/r0rr3r r r __and__s   z PBag.__and__cCs t|jS)z Hash based on value of elements. >>> m = pmap({pbag([1, 2]): "it's here!"}) >>> m[pbag([2, 1])] "it's here!" >>> pbag([1, 1, 2]) in m False )hashr)rr r r __hash__s z PBag.__hash__N)__name__ __module__ __qualname____doc__ __slots__rrrrrrr!r"r%r)r*__le____gt____ge__r2r4r6r8r:r r r r r s*     rcGst|S)z Construct a persistent bag. Takes an arbitrary number of arguments to insert into the new persistent bag. >>> b(1, 2, 3, 2) pbag([1, 2, 2, 3]) )pbag)elementsr r r bs rEcCs|stSttt|tS)z Convert an iterable to a persistent bag. Takes an iterable with elements to insert. >>> pbag([1, 2, 3, 2]) pbag([1, 2, 2, 3]) ) _EMPTY_PBAGrrrr)rDr r r rCs rCN)_compatrrrr functoolsrZpyrsistent._pmaprrobjectrregisterrErCrFr r r r s  `