%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyrsistent/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyrsistent/__pycache__/_pbag.cpython-312.pyc

�

n�9e���0�ddlmZmZmZmZddlmZddlmZm	Z	ddl
mZe	dd��Zd�Z
Gd	�d
ee�Zeje�eje�eje�eje�d�Zd�Zee��Zy
)�)�	Container�Iterable�Sized�Hashable)�reduce)�Generic�TypeVar)�pmap�T_coT)�	covariantc�L�|j||j|d�dz�S)Nr�)�set�get)�counters�elements  �2/usr/lib/python3/dist-packages/pyrsistent/_pbag.py�_add_to_countersr	s#���<�<�����g�q�!9�A�!=�>�>�c��eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZeZeZeZd�Zd�Zd�Zd�Zd�Zy)�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��||_y)N�r)�self�countss  r�__init__z
PBag.__init__&s	����rc�@�tt|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�rrs  r�addzPBag.add)s���$�T�\�\�7�;�<�<rc�R�|r$ttt||j��S|S)z�
        Update bag with all elements in iterable.

        >>> s = pbag([1])
        >>> s.update([1, 2])
        pbag([1, 1, 2])
        )rrrr)r�iterables  r�updatezPBag.update7s%�����/��4�<�<�H�I�I��rc��||jvrt|��|j|dk(r&|jj|�}t	|�S|jj||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)r�KeyError�removerr)rr�newcs   rr'zPBag.removeDs|���$�,�,�&��7�#�#�
�\�\�'�
"�a�
'��<�<�&�&�w�/�D��D�z���<�<�#�#�G�T�\�\�'�-B�Q�-F�G�D��D�z�rc�:�|jj|d�S)z�
        Return the number of times an element appears.


        >>> pbag([]).count('non-existent')
        0
        >>> pbag([1, 1, 2]).count(1)
        2
        r)rrr s  r�countz
PBag.countXs���|�|�����+�+rc�H�t|jj��S)ze
        Return the length including duplicates.

        >>> len(pbag([1, 1, 2]))
        3
        )�sumr�
itervalues�rs r�__len__zPBag.__len__ds���4�<�<�*�*�,�-�-rc#�xK�|jj�D]\}}t|�D]}|����y�w)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�	iteritems�range)r�eltr*�is    r�__iter__z
PBag.__iter__ms@�����,�,�0�0�2�	�J�C���5�\�
���	�
�	�s�8:c��||jvS)z�
        Check if an element is in the bag.

        >>> 1 in pbag([1, 1, 2])
        True
        >>> 0 in pbag([1, 2])
        False
        r)rr3s  r�__contains__zPBag.__contains__zs���d�l�l�"�"rc�6�djt|��S)Nz	pbag({0}))�format�listr.s r�__repr__z
PBag.__repr__�s���!�!�$�t�*�-�-rc�l�t|�turtd��|j|jk(S)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�r�others  r�__eq__zPBag.__eq__�s/����;�d�"��>�?�?��|�|�u�}�}�,�,rc��td��)NzPBags are not orderable)r>r?s  r�__lt__zPBag.__lt__�s���1�2�2rc��t|t�stS|jj	�}|jj�D]\}}|j
|�|z||<�t|j��S)z�
        Combine elements from two PBags.

        >>> pbag([1, 2, 2]) + pbag([2, 3, 3])
        pbag([1, 2, 2, 2, 3, 3])
        )�
isinstancer�NotImplementedr�evolverr1r*�
persistent)rr@�result�elem�other_counts     r�__add__zPBag.__add__�sr���%��&�!�!����%�%�'��!&���!8�!8�!:�	:��D�+��:�:�d�+�k�9�F�4�L�	:��F�%�%�'�(�(rc�B�t|t�stS|jj	�}|jj�D]:\}}|j
|�|z
}|dkDr|||<�%||vs�*|j|��<t|j��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)	rErrFrrGr1r*r'rH)rr@rIrJrK�newcounts      r�__sub__zPBag.__sub__�s����%��&�!�!����%�%�'��!&���!8�!8�!:�	$��D�+��z�z�$�'�+�5�H��!�|�'��t������
�
�d�#�	$��F�%�%�'�(�(rc��t|t�stS|jj	�}|jj�D]'\}}|j
|�}t||�}|||<�)t|j��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])
        )	rErrFrrGr1r*�maxrH)rr@rIrJrKr*rNs       r�__or__zPBag.__or__�s����%��&�!�!����%�%�'��!&���!8�!8�!:�	$��D�+��J�J�t�$�E��5�+�.�H�#�F�4�L�	$��F�%�%�'�(�(rc� �t|t�stSt�j	�}|j
j
�D]+\}}t||j|��}|dkDs�'|||<�-t|j��S)z�
        Intersection: Only keep elements that are present in both PBags.

        >>> pbag([1, 2, 2, 2]) & pbag([2, 3, 3])
        pbag([2])
        r)
rErrFr
rGrr1�minr*rH)rr@rIrJr*rNs      r�__and__zPBag.__and__�s}���%��&�!�!�����!���<�<�1�1�3�	(�K�D�%��5�%�+�+�d�"3�4�H��!�|�'��t��	(��F�%�%�'�(�(rc�,�t|j�S)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__�s���D�L�L�!�!rN)�__name__�
__module__�__qualname__�__doc__�	__slots__rr!r$r'r*r/r5r7r;rArC�__le__�__gt__�__ge__rLrOrRrUrX�rrrr
so���,+�I��=���(
,�.��	#�.�-�3��F�
�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])
    )�pbag��elementss r�brf�s����>�rc�V�|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_PBAGrrrr
rds rrcrc�s$�������'��4�6�:�;�;rN)�collections.abcrrrr�	functoolsr�typingrr	�pyrsistent._pmapr
rrr�registerrfrcrhrarr�<module>rns���@�@��#�!��v��&��?�\"�7�4�=�\"�~�	���4������$������t������$��
�<��4�6�l�r

Zerion Mini Shell 1.0