
    .Phʂ                         d Z ddlmZ ddlmZ ddlmZmZ ddlZ	 ddl	m
Z
  e
d	          Zn# e$ r  e            ZY nw xY wd
dgZdZ G d d
e          Zd Zd Zd Z G d d          ZdS )a  
The :class:`set` type brings the practical expressiveness of
set theory to Python. It has a very rich API overall, but lacks a
couple of fundamental features. For one, sets are not ordered. On top
of this, sets are not indexable, i.e, ``my_set[8]`` will raise an
:exc:`TypeError`. The :class:`IndexedSet` type remedies both of these
issues without compromising on the excellent complexity
characteristics of Python's built-in set implementation.
    )bisect_left)
MutableSet)chainisliceN   )make_sentinel_MISSING)var_name
IndexedSet
complement   c                   X   e Zd ZdZd.dZed             Zd Zd Zd Z	d Z
d.d	Zd
 Zd Zd Zd Zd Zd Zed             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z exZ!Z"exZ#Z$eZ%e xZ&Z'd Z(d Z)d  Z*d! Z+d" Z,d# Z-d$ Z.d% Z/d& Z0d.d'Z1d( Z2d.d)Z3d* Z4d+ Z5d, Z6d- Z7dS )/r   a   ``IndexedSet`` is a :class:`collections.MutableSet` that maintains
    insertion order and uniqueness of inserted elements. It's a hybrid
    type, mostly like an OrderedSet, but also :class:`list`-like, in
    that it supports indexing and slicing.

    Args:
        other (iterable): An optional iterable used to initialize the set.

    >>> x = IndexedSet(list(range(4)) + list(range(8)))
    >>> x
    IndexedSet([0, 1, 2, 3, 4, 5, 6, 7])
    >>> x - set(range(2))
    IndexedSet([2, 3, 4, 5, 6, 7])
    >>> x[-1]
    7
    >>> fcr = IndexedSet('freecreditreport.com')
    >>> ''.join(fcr[:fcr.index('.')])
    'frecditpo'

    Standard set operators and interoperation with :class:`set` are
    all supported:

    >>> fcr & set('cash4gold.com')
    IndexedSet(['c', 'd', 'o', '.', 'm'])

    As you can see, the ``IndexedSet`` is almost like a ``UniqueList``,
    retaining only one copy of a given value, in the order it was
    first added. For the curious, the reason why IndexedSet does not
    support setting items based on index (i.e, ``__setitem__()``),
    consider the following dilemma::

      my_indexed_set = [A, B, C, D]
      my_indexed_set[2] = A

    At this point, a set requires only one *A*, but a :class:`list` would
    overwrite *C*. Overwriting *C* would change the length of the list,
    meaning that ``my_indexed_set[2]`` would not be *A*, as expected with a
    list, but rather *D*. So, no ``__setitem__()``.

    Otherwise, the API strives to be as complete a union of the
    :class:`list` and :class:`set` APIs as possible.
    Nc                     t                      | _        g | _        g | _        d| _        d| _        |r|                     |           d S d S Nr   )dictitem_index_map	item_listdead_indices_compactions_c_max_sizeupdateselfothers     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/boltons/setutils.py__init__zIndexedSet.__init__o   sW    "ff 	KK	 	    c                 T    t          | j                  t          | j                  z
  S N)lenr   r   r   s    r   _dead_index_countzIndexedSet._dead_index_county   s"    4>""S)<%=%===r   c                    | j         sd S | xj        dz  c_        | j        }| j        | j        }}t          | j        t          |                    | _        t          |           D ]\  }}|||<   |||<   || d = | j         d d = d S )Nr   )	r   r   r"   r   r   maxr   r    	enumerate)r   dead_index_countitems	index_mapiitems         r   _compactzIndexedSet._compact}   s      	FQ1>4+>yt/U<<  	  	 GAtE!HIdOO##$$%aaa   r   c                    | j         }|sd S | j        | j        }}|s|d d = |d d = d S t          |          dk    r|                                  d S | j        t          |          t          z  k    r|                                  d S |d         t          u rYd}||dz             t          u r|dz  }||dz             t          u |r"|d         d         t          |          k    r|d= || d = d S d S )Ni  r   )r   r   r   r    r+   r"   _COMPACTION_FACTORr	   )r   dedr'   ii_mapnum_deads        r   _cullzIndexedSet._cull   s     	F(;v 	"aaaAAAXX^^MMOOOOO#s5zz4F'FGGMMOOOOO2Y(""H(Q,(H44A (Q,(H44 s2wqzSZZ//Gxijj!!! #"r   c                     |dk     r|t          |           z  }| j        s|S |}| j        D ]\  }}||k     r n	|||z
  z  }|S r   r    r   )r   index
real_indexd_startd_stops        r   _get_real_indexzIndexedSet._get_real_index   sm    199SYYE  	L
#0 	+ 	+OGVG##&7**JJr   c                     |dk     r|t          |           z  }| j        s|S |}| j        D ]\  }}||k     r n	|||z
  z  }|S r   r4   )r   r5   apparent_indexr7   r8   s        r   _get_apparent_indexzIndexedSet._get_apparent_index   sk    199SYYE  	L#0 	/ 	/OGVwfw..NNr   c                     | j         }||dz   }||g}|s|                    |           d S t          ||          }||dz
           }|\  }}||cxk    r|k    r	n n||d<   n,||cxk    r|k    r	n n||d<   n|                    ||           d S )Nr   r   )r   appendr   insert)	r   startstopdintscand_intint_idxdintr7   r8   s	            r   	_add_deadzIndexedSet._add_dead   s     !<19D4= 	LL"""FeX..Wq[!G####t#####DGGf$$$$$$$$$DGGLL(+++r   c                 *    t          | j                  S r   r    r   r!   s    r   __len__zIndexedSet.__len__   s    4&'''r   c                     || j         v S r   r   r   r*   s     r   __contains__zIndexedSet.__contains__   s    t***r   c                 $    d | j         D             S )Nc              3   ,   K   | ]}|t           u|V  d S r   r	   .0r*   s     r   	<genexpr>z&IndexedSet.__iter__.<locals>.<genexpr>   s,      HH4x3G3G3G3G3G3GHHr   )r   r!   s    r   __iter__zIndexedSet.__iter__   s    HHHHHHr   c                 B    | j         }d t          |          D             S )Nc              3   ,   K   | ]}|t           u|V  d S r   rP   rQ   s     r   rS   z*IndexedSet.__reversed__.<locals>.<genexpr>   s,      MMH8L8L8L8L8L8LMMr   )r   reversed)r   r   s     r   __reversed__zIndexedSet.__reversed__   s%    N	MM)!4!4MMMMr   c                 @    | j         j         dt          |           dS )N())	__class____name__listr!   s    r   __repr__zIndexedSet.__repr__   s$    .);;DJJ;;;;r   c                    t          |t                    r@t          |           t          |          k    ot          |           t          |          k    S 	 t	          |           t	          |          k    S # t
          $ r Y dS w xY wNF)
isinstancer   r    r^   set	TypeErrorr   s     r   __eq__zIndexedSet.__eq__   s    eZ(( 	It99E

*HtDzzT%[[/HH	t99E

** 	 	 	55	s   A7 7
BBc                      | |          S )z2from_iterable(it) -> create a set from an iterable )clsits     r   from_iterablezIndexedSet.from_iterable   s     s2wwr   c                     || j         vr8t          | j                  | j         |<   | j                            |           dS dS )z add(item) -> add item to the setN)r   r    r   r>   rL   s     r   addzIndexedSet.add   sK    t***(+DN(;(;D%N!!$''''' +*r   c                     	 | j                             |          }n# t          $ r t          |          w xY wt          | j        |<   |                     |           |                                  dS )z?remove(item) -> remove item from the set, raises if not presentN)r   popKeyErrorr	   r   rF   r2   )r   r*   didxs      r   removezIndexedSet.remove   su    	!&**400DD 	! 	! 	!4.. 	!'tt

s    7c                 T    	 |                      |           dS # t          $ r Y dS w xY w)z;discard(item) -> discard item from the set (does not raise)N)rq   ro   rL   s     r   discardzIndexedSet.discard   sA    	KK 	 	 	DD	s    
''c                 `    | j         dd= | j        dd= | j                                         dS )zclear() -> empty the setN)r   r   r   clearr!   s    r   ru   zIndexedSet.clear  s:    N111aaa !!#####r   c                 ,    | j         }|D ]	}||v r dS 
dS )z9isdisjoint(other) -> return True if no overlap with otherFTrK   r   r   iimks       r   
isdisjointzIndexedSet.isdisjoint  s3    ! 	 	ACxxuu tr   c                 l    t          |          t          |           k     rdS | j        D ]	}||vr dS 
dS )z9issubset(other) -> return True if other contains this setFTrH   )r   r   ry   s      r   issubsetzIndexedSet.issubset  sJ    u::D		!!5$ 	 	A~~uu tr   c                 p    t          |          t          |           k    rdS | j        }|D ]	}||vr dS 
dS )z6issuperset(other) -> return True if set contains otherFTrH   rw   s       r   
issupersetzIndexedSet.issuperset  sO    u::D		!!5! 	 	A||uu tr   c                 B    |                      t          | g|R            S )zAunion(*others) -> return a new set containing this set and others)rj   r   r   otherss     r   unionzIndexedSet.union"  s&    !!%"6v"6"6"6777r   c              '   2   K   | D ]}|D ]}||vr n	|V  dS )zBiter_intersection(*others) -> iterate over elements also in othersNrg   r   r   ry   r   s       r   iter_intersectionzIndexedSet.iter_intersection&  sH       	 	A  E>>E " r   c                     t          |          dk    r)|d         |                     fd| D                       S |                      | j        |           S )zBintersection(*others) -> get a set with overlap of this and othersr   r   c              3   $   K   | ]
}|v |V  d S r   rg   rR   ry   r   s     r   rS   z*IndexedSet.intersection.<locals>.<genexpr>4  s'      %D%DAea%D%Dr   )r    rj   r   r   r   r   s     @r   intersectionzIndexedSet.intersection0  se    v;;!1IE%%%D%D%D%D%D%D%DDDD!!"8$"8&"ABBBr   c              '   2   K   | D ]}|D ]}||v r n	|V  dS )z?iter_difference(*others) -> iterate over elements not in othersNrg   r   s       r   iter_differencezIndexedSet.iter_difference7  sH       	 	A  ::E  r   c                     t          |          dk    r)|d         |                     fd| D                       S |                      | j        |           S )z@difference(*others) -> get a new set with elements not in othersr   r   c              3   $   K   | ]
}|v|V  d S r   rg   r   s     r   rS   z(IndexedSet.difference.<locals>.<genexpr>E  s'      %H%HA%a%H%Hr   )r    rj   r   r   s     @r   
differencezIndexedSet.differenceA  se    v;;!1IE%%%H%H%H%H%H%H%HHHH!!"6$"6"?@@@r   c                 P     | j         | }|                     | j        |           S )z;symmetric_difference(*others) -> XOR set of this and others)r   r   r   )r   r   rets      r   symmetric_differencezIndexedSet.symmetric_differenceH  s-    dj&!~~/d/8999r   c                 P      fd|D             } t          |          |          S )Nc                     g | ]}|v|	S rg   rg   )rR   xr   s     r   
<listcomp>z'IndexedSet.__rsub__.<locals>.<listcomp>S  s    222aATMMMMMr   )type)r   r   valss   `  r   __rsub__zIndexedSet.__rsub__R  s2    22225222tE{{4   r   c                     |sdS t          |          dk    r	|d         }nt          |          }|D ]}|                     |           dS )z8update(*others) -> add values from one or more iterablesNr   r   )r    r   rl   )r   r   r   os       r   r   zIndexedSet.updateW  s`     	"F[[A1IEE&MME 	 	AHHQKKKK	 	r   c                 J     | j         | D ]}|                     |           dS )z@intersection_update(*others) -> discard self.difference(*others)N)r   rs   r   r   vals      r   intersection_updatezIndexedSet.intersection_updateb  s9    "4?F+ 	 	CLL	 	r   c                 z    | |v r|                                    | j        | D ]}|                     |           dS )z@difference_update(*others) -> discard self.intersection(*others)N)ru   r   rs   r   s      r   difference_updatezIndexedSet.difference_updateg  sP    6>>JJLLL$4$f- 	 	CLL	 	r   c                     | |u r|                                   |D ]1}|| v r|                     |           |                     |           2dS )z=symmetric_difference_update(other) -> in-place XOR with otherN)ru   rs   rl   )r   r   r   s      r   symmetric_difference_updatez&IndexedSet.symmetric_difference_updaten  s`    5==JJLLL 	 	Cd{{S!!!!		 	r   c                      | j         |  | S r   )r   r   s     r   __ior__zIndexedSet.__ior__x  s    Vr   c                      | j         |  | S r   )r   r   s     r   __iand__zIndexedSet.__iand__|  s      &))r   c                      | j         |  | S r   )r   r   s     r   __isub__zIndexedSet.__isub__  s    ''r   c                      | j         |  | S r   )r   r   s     r   __ixor__zIndexedSet.__ixor__  s    ((&11r   c                     | }||                      |          }||                      |          }||dk     r| }t          |           }t          ||||          S )ziterate over a slice of the setNr   )r9   rW   r   )r   r@   rA   stepiterables        r   
iter_slicezIndexedSet.iter_slice  sm    ((//E''--Dq5D~~HhtT222r   c                    	 |j         |j        |j        }}}|                     |||          }|                     |          S # t
          $ r t          j        |          }Y nw xY w|dk     r|t          |           z  }| 	                    |          }	 | j
        |         }n# t          $ r t          d          w xY w|S )Nr   zIndexedSet index out of range)r@   rA   r   r   rj   AttributeErroroperatorr5   r    r9   r   
IndexError)r   r5   r@   rA   r   r   r6   r   s           r   __getitem__zIndexedSet.__getitem__  s    	2 %UZ4E d;;J%%j111	  	* 	* 	*N5))EEE	*
 199SYYE))%00
	>.,CC 	> 	> 	><===	>
s   A A$#A$B# #B=c                 H   | j         }t          |          }||dk    s	||dz
  k    r| j                                        }||= nI|                     |          }| j        |         }t
          | j        |<   ||= |                     |           |                                  |S )z>pop(index) -> remove the item at a given index (-1 by default)Nr-   r   )r   r    r   rn   r9   r	   rF   r2   )r   r5   r   len_selfr   r6   s         r   rn   zIndexedSet.pop  s    ,~&&=ERKK5HqL+@+@.$$&&Cs##--e44J.,C)1DN:&s#NN:&&&


r   c                     || j         v rdS dS )z9count(val) -> count number of instances of value (0 or 1)r   r   rK   )r   r   s     r   countzIndexedSet.count  s    $%%%1qr   c                     t          t          |                     }|| j        dd<   t          | j                  D ]\  }}|| j        |<   | j        dd= dS )z5reverse() -> reverse the contents of the set in-placeN)r^   rW   r   r%   r   r   )r   reversed_listr)   r*   s       r   reversezIndexedSet.reverse  sg    Xd^^,,)qqq 00 	* 	*GAt()D%%aaa   r   c                     t          | fi |}|| j        k    rdS || j        dd<   t          | j                  D ]\  }}|| j        |<   | j        dd= dS )z/sort() -> sort the contents of the set in-placeN)sortedr   r%   r   r   )r   kwargssorted_listr)   r*   s        r   sortzIndexedSet.sort  s{    T,,V,,$.((F'qqq 00 	* 	*GAt()D%%aaa   r   c                     	 |                      | j        |                   S # t          $ r! | j        j        }t          |d|           w xY w)z=index(val) -> get the index of a value, raises if not presentz is not in )r<   r   ro   r\   r]   
ValueError)r   r   cns      r   r5   zIndexedSet.index  sd    	8++D,?,DEEE 	8 	8 	8(B66"66777	8s	   " +Ar   )8r]   
__module____qualname____doc__r   propertyr"   r+   r2   r9   r<   rF   rI   rM   rT   rX   r_   re   classmethodrj   rl   rq   rs   ru   rz   r|   r~   r   r   r   r   r   r   __or____ror____and____rand____sub____xor____rxor__r   r   r   r   r   r   r   r   r   r   r   rn   r   r   r   r5   rg   r   r   r   r   D   s       ) )T    > > X>! ! !" " "(
 
 

 
 
   ,( ( (+ + +I I IN N N< < <     [
( ( (    $ $ $      8 8 8  C C C  A A A: : :
 Fg%%GhG--Gh! ! !
	 	 	  
            
3 
3 
3 
3  "      ! ! !! ! !8 8 8 8 8r   c                     t          |           t          u r|                                 S t          |           t          u rt          |           S t          t	          |                     S )a  Given a :class:`set`, convert it to a **complement set**.

    Whereas a :class:`set` keeps track of what it contains, a
    `complement set
    <https://en.wikipedia.org/wiki/Complement_(set_theory)>`_ keeps
    track of what it does *not* contain. For example, look what
    happens when we intersect a normal set with a complement set::

    >>> list(set(range(5)) & complement(set([2, 3])))
    [0, 1, 4]

    We get the everything in the left that wasn't in the right,
    because intersecting with a complement is the same as subtracting
    a normal set.

    Args:
        wrapped (set): A set or any other iterable which should be
           turned into a complement set.

    All set methods and operators are supported by complement sets,
    between other :func:`complement`-wrapped sets and/or regular
    :class:`set` objects.

    Because a complement set only tracks what elements are *not* in
    the set, functionality based on set contents is unavailable:
    :func:`len`, :func:`iter` (and for loops), and ``.pop()``. But a
    complement set can always be turned back into a regular set by
    complementing it again:

    >>> s = set(range(5))
    >>> complement(complement(s)) == s
    True

    .. note::

       An empty complement set corresponds to the concept of a
       `universal set <https://en.wikipedia.org/wiki/Universal_set>`_
       from mathematics.

    Complement sets by example
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

    Many uses of sets can be expressed more simply by using a
    complement. Rather than trying to work out in your head the proper
    way to invert an expression, you can just throw a complement on
    the set. Consider this example of a name filter::

        >>> class NamesFilter(object):
        ...    def __init__(self, allowed):
        ...        self._allowed = allowed
        ...
        ...    def filter(self, names):
        ...        return [name for name in names if name in self._allowed]
        >>> NamesFilter(set(['alice', 'bob'])).filter(['alice', 'bob', 'carol'])
        ['alice', 'bob']

    What if we want to just express "let all the names through"?

    We could try to enumerate all of the expected names::

       ``NamesFilter({'alice', 'bob', 'carol'})``

    But this is very brittle -- what if at some point over this
    object is changed to filter ``['alice', 'bob', 'carol', 'dan']``?

    Even worse, what about the poor programmer who next works
    on this piece of code?  They cannot tell whether the purpose
    of the large allowed set was "allow everything", or if 'dan'
    was excluded for some subtle reason.

    A complement set lets the programmer intention be expressed
    succinctly and directly::

       NamesFilter(complement(set()))

    Not only is this code short and robust, it is easy to understand
    the intention.

    excluded)r   _ComplementSetcomplemented	frozensetrc   )wrappeds    r   r   r     sa    ` G}}&&##%%%G}}	!!w////3w<<0000r   c                     t          |           t          t          fv r| d}}n4t          |           t          u r| j        | j        }}nt          d          ||fS )z9normalize args and raise type-error if there is a problemN/argument must be another set or complement(set))r   rc   r   r   	_included	_excludedrd   r   incexcs      r   _norm_args_typeerrorr   .  s[    E{{sI&&&$S	e	&	&?EOSIJJJ8Or   c                     t          |           t          t          fv r| d}}n.t          |           t          u r| j        | j        }}n	t          dfS ||fS )zCnormalize args and return NotImplemented (for overloaded operators)N)r   rc   r   r   r   r   NotImplementedr   s      r   _norm_args_notimplementedr   9  sW    E{{sI&&&$S	e	&	&?EOSt##8Or   c                       e Zd ZdZdZd(dZd Zd ZeZd Z	d Z
d	 Zd
 Zd Zd Zd ZeZd Zd Zd ZeZd Zd Zd Zd Zd ZeZd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(d$ Z)d% Z*d& Z+d' Z,dS ))r   zG
    helper class for complement() that implements the set methods
    r   r   Nc                     | t          |          t          t          fv sJ n1| t          |          t          t          fv sJ nt          d          ||c| _        | _        d S )Nz)one of included or excluded must be a set)r   rc   r   r   r   r   )r   includedr   s      r   r   z_ComplementSet.__init__J  so    >>c9%555555>>c9%555555HIII)18&r   c                 p    | j         dt          | j                   dS dt          | j                    dS )Nzcomplement(r[   zcomplement(complement(z)))r   reprr   r!   s    r   r_   z_ComplementSet.__repr__S  s@    >!8dn!5!58888@T^(<(<@@@@r   c                 2   t          | j                  t          u st          | j                  t          u rt	          | j        | j                  S t	          | j        dnt          | j                  | j        dnt          | j                            S )z&return a complement of the current set)r   r   N)r   r   r   r   r   rc   r!   s    r   r   z_ComplementSet.complementedX  s    9,,T^0D0D	0Q0Q!4>DNSSSS!^3TTT^9L9L!^3TTT^9L9LN N N 	Nr   c                 8    | j         | j        c| _        | _         dS )z2convert the current set to its complement in-placeN)r   r   r!   s    r   r   z_ComplementSet.complementb  s    )-&r   c                 4    | j         	|| j        vS || j         v S r   r   rL   s     r   rM   z_ComplementSet.__contains__f  s$    >!t~--t~%%r   c                     | j         '|| j        v r| j                            |           d S d S | j                             |           d S r   )r   r   rq   rl   rL   s     r   rl   z_ComplementSet.addk  sY    >!t~%%%%d+++++ &% Nt$$$$$r   c                     | j         | j                            |           d S | j                             |           d S r   )r   r   rl   rq   rL   s     r   rq   z_ComplementSet.remover  sB    >!Nt$$$$$N!!$'''''r   c                 P    | j         t          | j                                         S r   )r   NotImplementedErrorrn   r!   s    r   rn   z_ComplementSet.popx  s$    >!%%~!!###r   c                 H    	 | |z  S # t           $ r t          d          w xY wNr   r   rd   r   s     r   r   z_ComplementSet.intersection}  @    	O%<" 	O 	O 	OMNNN	O    !c                 f   t          |          \  }}|t          u rt          S | j        G|t          || j        z
            S t          | j                            |j                            S |t          || j        z
            S t          | j                            |                    S Nr   r   )r   r   r   r   r   r   r   r   r   r   r   s       r   r   z_ComplementSet.__and__  s    ,U33S.  !!>!{%sT^/CDDDD%t~/C/CEO/T/TUUUU{%sT^/CDDDD%t~/J/J3/O/OPPPPr   c                    t          |          \  }}|t          u rt          S | j        #||| j        z
  | _        nH| xj        |z  c_        n7|%| xj        |z  c_        d | j        c| _        | _        n| xj        |z  c_        | S r   r   r   r   r   r   s       r   r   z_ComplementSet.__iand__  s    ,U33S.  !!>!{!$t~!5#%{#%15t~.#%r   c                 H    	 | |z  S # t           $ r t          d          w xY wr   r   r   s     r   r   z_ComplementSet.union  r   r   c                 \   t          |          \  }}|t          u rt          S | j        B|t          | j        |z
            S t          | j                            |                    S |t          || j        z
            S t          | j                            |                    S Nr   r   )r   r   r   r   r   r   r   r   s       r   r   z_ComplementSet.__or__  s    ,U33S.  !!>!{%t~/CDDDD%t~/J/J3/O/OPPPP{%sT^/CDDDD%t~/C/CC/H/HIIIIr   c                     t          |          \  }}|t          u rt          S | j        $|| xj        |z  c_        n;| xj        |z  c_        n*|d || j        z
  c| _        | _        n| xj        |z  c_        | S r   r   r   s       r   r   z_ComplementSet.__ior__  s    ,U33S.  !!>!{#%#%{15sT^7K.#%r   c                    t          |          t          t          fv r|d }}n6t          |          t          u r|j        |j        }}nt          |          d }}| j        0|| xj        |z  c_        d S | j                            |           d S |&| xj        |z  c_        d | j        c| _        | _        d S | j                            |           d S r   )r   rc   r   r   r   r   rs   r   r   r'   r   r   s       r   r   z_ComplementSet.update  s    ;;3	***dCC%[[N**CC ''C>!{#%&&s+++++{#%15t~.%%c*****r   c                    t          |          t          t          fv r|d }}n6t          |          t          u r|j        |j        }}nt          |          d }}| j        7|| j                            |           d S || j        z
  d c| _        | _        d S || xj        |z  c_        d S | j                            |           d S r   )r   rc   r   r   r   r   r   rs   r   s       r   rs   z_ComplementSet.discard  s    ;;3	***dCC%[[N**CC ''C>!{%%c*****14t~1Et.{#%&&s+++++r   c                 H    	 | |z  S # t           $ r t          d          w xY wr   r   r   s     r   r   z#_ComplementSet.symmetric_difference  r   r   c                 |   t          |          \  }}|t          u rt          S |t          u rt          S | j        B|t          | j        |z
            S t          | j                            |                    S |t          || j        z
            S t          | j                            |                    S r   )r   r   r   r   r   r   r   s       r   r   z_ComplementSet.__xor__  s    ,U33S.  !!.  !!>!{%t~/CDDDD%t~/R/RSV/W/WXXXX{%sT^/CDDDD%t~/R/RSV/W/WXXXXr   c                 D   t          |          \  }}| j        D|| xj        |z  c_        d S | j                            |           | j        d c| _        | _        d S |&| xj        |z  c_        d | j        c| _        | _        d S | j                            |           d S r   )r   r   r   r   r   s       r   r   z*_ComplementSet.symmetric_difference_update
  s    '..S>!{#%::3???15.{#%15t~.::3?????r   c                     t          |          \  }}|t          u rt          S | j        ||                    | j                  S dS || j                            |          S | j                            |          S ra   )r   r   r   r|   r   rz   r   s       r   rz   z_ComplementSet.isdisjoint  s{    '..S.  !!>!{||DN333u{~..s333~00555r   c                 J    	 | |k    S # t           $ r t          d          w xY w)z7everything missing from other is also missing from selfr   r   r   s     r   r|   z_ComplementSet.issubset(  @    	O5= " 	O 	O 	OMNNN	O    "c                    t          |          \  }}|t          u rt          S |t          u rt          S | j        |dS | j                            |          S || j                            |          S | j                            |          S ra   )r   r   r   r   issupsersetrz   r|   r   s       r   __le__z_ComplementSet.__le__/  s    ,U33S.  !!.  !!>!{u~11#666{~00555~..s333r   c                     t          |          \  }}|t          u rt          S |t          u rt          S | j        |dS | j        |k    S || j                            |          S | j        |k     S ra   )r   r   r   r   rz   r   s       r   __lt__z_ComplementSet.__lt__@  s|    ,U33S.  !!.  !!>!{u~++{~00555~++r   c                 J    	 | |k    S # t           $ r t          d          w xY w)z7everything missing from self is also missing from superr   r   r   s     r   r~   z_ComplementSet.issupersetQ  r  r  c                     t          |          \  }}|t          u rt          S | j        7|| j                            |           S | j                            |          S |dS | j                            |          S ra   )r   r   r   r   r   r|   r	  r   s       r   __ge__z_ComplementSet.__ge__X  s    ,U33S.  !!>!{>66s;;;;~..s333{u~11#666r   c                     t          |          \  }}|t          u rt          S | j        (|| j                            |           S | j        |k     S |dS | j        |k    S ra   )r   r   r   r   r   r   s       r   __gt__z_ComplementSet.__gt__g  sn    ,U33S.  !!>!{>66s;;;;~++{u~++r   c                 H    	 | |z
  S # t           $ r t          d          w xY wr   r   r   s     r   r   z_ComplementSet.differencev  r   r   c                 <   t          |          \  }}|t          u rt          S | j        2|t          | j        |z            S t          || j        z
            S |t          | j        |z            S t          | j                            |                    S r   r   r   r   r   r   r   r   s       r   r   z_ComplementSet.__sub__|  s    ,U33S.  !!>!{%t~/CDDDD%sT^/CDDDD{%t~/CDDDD%t~/H/H/M/MNNNNr   c                 <   t          |          \  }}|t          u rt          S | j        2|t          || j        z            S t          | j        |z
            S |t          || j        z            S t          |                    | j                            S r   r  r   s       r   r   z_ComplementSet.__rsub__  s    ,U33S.  !!>!{%sT^/CDDDD%t~/CDDDD{%sT^/CDDDD%s~~dn/M/MNNNNr   c                 L    	 | |z  } d S # t           $ r t          d          w xY wr   r   r   s     r   r   z _ComplementSet.difference_update  sC    	OEMDDD" 	O 	O 	OMNNN	Os   	 #c                    t          |          \  }}|t          u rt          S | j        +|| xj        |z  c_        nE|| j        z
  d c| _        | _        n-|| xj        |z  c_        n| j                            |           | S r   )r   r   r   r   r   r   s       r   r   z_ComplementSet.__isub__  s    ,U33S.  !!>!{#%14t~1Et.{#%00555r   c                     t          |           t          |          u o| j        |j        k    o| j        |j        k    p't          |          t          t          fv o
| j        |k    S r   )r   r   r   rc   r   r   s     r   re   z_ComplementSet.__eq__  se    JJ$u++% 2%/12%/1I KKC++G%0G		Ir   c                 T    t          | j                  t          | j                  z  S r   )hashr   r   r!   s    r   __hash__z_ComplementSet.__hash__  s!    DN##d4>&:&:::r   c                 V    | j         t          | j                   S t          d          )Nz'complemented sets have undefined length)r   r    r   r!   s    r   rI   z_ComplementSet.__len__  s)    >%t~&&&!"KLLLr   c                 V    | j         t          | j                   S t          d          )Nz)complemented sets have undefined contents)r   iterr   r!   s    r   rT   z_ComplementSet.__iter__  s)    >%'''!"MNNNr   c                 <    | j         t          | j                   S dS )NT)r   boolr!   s    r   __bool__z_ComplementSet.__bool__  s    >%'''tr   )NN)-r]   r   r   r   	__slots__r   r_   r   
__invert__r   rM   rl   rq   rn   r   r   r   r   r   r   r   r   r   rs   r   r   r   r   rz   r|   r
  r  r~   r  r  r   r   r   r   r   re   r  rI   rT   r!  rg   r   r   r   r   D  s         +I< < < <A A A
N N N JH H H& & &
% % %( ( ($ $ $
O O OQ Q Q H  "O O OJ J J G   + + +&, , ,$O O OY Y Y" H@ @ @6 6 6O O O4 4 4", , ,"O O O7 7 7, , ,O O OO O OO O O O O O   I I I; ; ;M M M
O O O
    r   r   )r   bisectr   collections.abcr   	itertoolsr   r   r   	typeutilsr   r	   ImportErrorobject__all__r.   r   r   r   r   r   rg   r   r   <module>r+     s_  >	 	       & & & & & & # # # # # # # # ((((((}j111HH   vxxHHH 
&  P8 P8 P8 P8 P8 P8 P8 P8fT1 T1 T1n    D D D D D D D D D Ds   / A A