Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/__pycache__/_pbag.cpython-311.pyc



]jJ
ddlmZmZmZmZddlmZddlmZdZ	Gdde
ZejeejeejeejedZ
dZeeZd	S)
)	ContainerIterableSizedHashable)reduce)pmapc\||||ddzS)Nr)setget)counterselements  p/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/_pbag.py_add_to_countersrs)<<gq!9!9A!=>>>ceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZeZeZeZdZdZdZdZdZdS)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__c||_dS)Nr)selfcountss  r__init__z
PBag.__init__#s
rcFtt|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])
        )rrrrrs  raddzPBag.add&s$T\7;;<<<rcZ|r(ttt||jS|S)z
        Update bag with all elements in iterable.

        >>> s = pbag([1])
        >>> s.update([1, 2])
        pbag([1, 1, 2])
        )rrrr)riterables  rupdatezPBag.update4s/	J/4<HHIIIrc||jvrt||j|dkr|j|}n)|j||j|dz
}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
)rKeyErrorremoverr)rrnewcs   rr#zPBag.removeAsw$,&&7###
\'
"a
'
'<&&w//DD<##GT\'-BQ-FGGDDzzrc8|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rs  rcountz
PBag.countUs|+++rcNt|jS)ze
        Return the length including duplicates.

        >>> len(pbag([1, 1, 2]))
        3
        )sumr
itervaluesrs r__len__zPBag.__len__as 4<**,,---rc#tK|jD]\}}t|D]}|VdS)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)reltr&is    r__iter__z
PBag.__iter__jsX,0022		JC5\\

				
		rc||jvS)z
        Check if an element is in the bag.

        >>> 1 in pbag([1, 1, 2])
        True
        >>> 0 in pbag([1, 2])
        False
        r)rr/s  r__contains__zPBag.__contains__wsdl""rcFdt|S)Nz	pbag({0}))formatlistr*s r__repr__z
PBag.__repr__s!!$t**---rclt|turtd|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	TypeErrorrrothers  r__eq__zPBag.__eq__s3;;d"">???|u},,rc td)NzPBags are not orderable)r:r;s  r__lt__zPBag.__lt__s1222rc"t|tstS|j}|jD] \}}|||z||<!t|S)z
        Combine elements from two PBags.

        >>> pbag([1, 2, 2]) + pbag([2, 3, 3])
        pbag([1, 2, 2, 2, 3, 3])
        )
isinstancerNotImplementedrevolverr-r&
persistent)rr<resultelemother_counts     r__add__zPBag.__add__s%&&	"!!%%''!&!8!8!:!:	:	:D+::d++k9F4LLF%%''(((rcft|tstS|j}|jD]B\}}|||z
}|dkr|||<)||vr||Ct|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)	rArrBrrCr-r&r#rD)rr<rErFrGnewcounts      r__sub__zPBag.__sub__s%&&	"!!%%''!&!8!8!:!:	$	$D+zz$''+5H!||'t

d###F%%''(((rc@t|tstS|j}|jD]/\}}||}t||}|||<0t|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])
        )	rArrBrrCr-r&maxrD)rr<rErFrGr&rJs       r__or__zPBag.__or__s%&&	"!!%%''!&!8!8!:!:	$	$D+JJt$$E5+..H#F4LLF%%''(((rcVt|tstSt}|jD]3\}}t|||}|dkr|||<4t|	S)z
        Intersection: Only keep elements that are present in both PBags.

        >>> pbag([1, 2, 2, 2]) & pbag([2, 3, 3])
        pbag([2])
        r)
rArrBrrCrr-minr&rD)rr<rErFr&rJs      r__and__zPBag.__and__s%&&	"!!!!<1133	(	(KD%5%++d"3"344H!||'tF%%''(((rc*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
        )hashrr*s r__hash__z
PBag.__hash__sDL!!!rN)__name__
__module____qualname____doc__	__slots__rrr r#r&r+r1r3r7r=r?__le____gt____ge__rHrKrNrQrTrrrr
s&,+I===(
,
,
,...	#	#	#...---333F
F
F))))))$))) ))) 
"
"
"
"
"rrc t|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])
    )pbagelementss rbrbs>>rcr|stSttt|t	S)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_PBAGrrrrr`s rr_r_s1'466::;;;rN)collections.abcrrrr	functoolsrpyrsistent._pmaprrobjectrregisterrbr_rdr]rr<module>rjs@@@@@@@@@@@@!!!!!!???\"\"\"\"\"6\"\"\"~	4$t$


<<<d4466llr
Back to Directory File Manager