
    J/Ph                     l
   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZm Z m!Z! d Z"d Z#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/ ej0        dd          Z1 G d de2          Z3 G d de2          Z4 G d d e2          Z5d! Z6 ee7          d"             Z8 ee7e
j9                  d#             Z: ee;e
j<                  d$             Z= eej>        e
j<        e
j?                  d%             Z@ ed&e
j<                  d'             ZA ed(e
jB                   eejC                  d)                         ZD ed*e
j<        e
j?                  d+             ZEe!d,             ZF e e
j<        d-          d.             ZGe!d/             ZH e e
j<        d0          d1             ZIe!d2             ZJ e e
j<        d3          d4             ZKe!d5             ZL e e
j<        d6          d7             ZMe!d8             ZN e e
j<        d9          d:             ZOd; ZPe!d<             ZQ e e
j<        d=          d>             ZRd? ZSe!d@             ZT e e
j<        dA          dB             ZUdC ZVe!dD             ZW e e
j<        dE          dF             ZX edGe
j<        e
j9                  dH             ZYdI ZZej[        eSfej\        eYfej]        ePfej^        eVffD ]\  Z_Z` eZe_e`            eeja                   e e
j<        dJ          dK                         Zb eejc                   e e
j<        dL          dM                         Zd eeje                   e e
j<        dN          dO                         Zf eejg                   e e
j<        dP          dQ                         Zhe!dR             Zi e e
j<        dS          dT             Zje!dU             Zk eejl                   e e
j<        dV          dW                         Zm eejn                   e e
j<        dX          dY                         Zoe!dZ             Zp eejq                  d[             Zr eejs                  d\             Zte!d]             Zu eejv                  d^             Zw eejx                  d_             Zy eejz        e
j<        e
j<                  d`             Z{ ee
j<        e
j<                  da             Z|dS )bz&
Support for native homogeneous sets.
    N)cached_property)ir)typestypingcgutils)	lower_builtin
lower_castiternext_implimpl_ret_borrowedimpl_ret_new_refimpl_ret_untrackedfor_itercall_lenRefType)	quicksort)slicing)NumbaValueErrorTypingError)overloadoverload_method	intrinsicc                     t          j        |          }|                     |                                          }|                    ||          }|                     |||          S )zx
    Given a set value and type, get its payload structure (as a
    reference, so that mutations are seen by all).
    ref)r   
SetPayloadget_data_type
as_pointerbitcastmake_data_helper)contextbuilderset_typeptrpayload_typeptrtypayloads          T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/cpython/setobj.pyget_payload_structr(      sa    
 #H--L!!,//::<<Eooc5))G##G\w#GGG    c                 z    |                      t          j        |                    }|                     |          S )z7
    Return the entry size for the given set type.
    )r   r   SetEntryget_abi_sizeof)r    r"   lltys      r'   get_entry_sizer.   #   s5       !9!9::D!!$'''r)   i      Fc                 H   | j         }|                    t                    }|                    ||fi           }|                     ||          } |||f          }t          | ||          }	t          j        |j        t                    }
|
                    |	||
          S )z.
    Compute the hash of the given value.
    )typing_contextresolve_value_typehashget_call_typeget_functionis_hash_usedr   ConstanttypeFALLBACKselect)r    r!   typvalue	typingctxfntysigfnhis_okfallbacks              r'   get_hash_valuerG   ;   s     &I''--D


Y
3
3C			dC	(	(B
7UHA'1--E{168,,H>>%H---r)   c                 z    fd}|                      t                    }|                    | fi           }||fS )Nc                 4    t          | ||d                   S Nr   )rG   )r    r!   r>   argsr?   s       r'   implz'_get_hash_value_intrinsic.<locals>.implL   s    gwtAw???r)   )r5   r6   r7   )r@   r?   rL   rA   rB   s    `   r'   _get_hash_value_intrinsicrM   J   sW    @ @ @ @ @''--D


Y"
5
5C9r)   c                 n    t          j        |j        t                    }|                    d||          S )z8
    Whether the hash value denotes an empty entry.
    ==)r   r:   r;   EMPTYicmp_unsigned)r    r!   rD   emptys       r'   is_hash_emptyrS   S   s/     K&&E  q%000r)   c                 n    t          j        |j        t                    }|                    d||          S )z9
    Whether the hash value denotes a deleted entry.
    rO   r   r:   r;   DELETEDrQ   r    r!   rD   deleteds       r'   is_hash_deletedrY   Z   s/     k!&'**G  q'222r)   c                 n    t          j        |j        t                    }|                    d||          S )z9
    Whether the hash value denotes an active entry.
    <rU   rW   s       r'   r9   r9   a   s/    
 k!&'**G  a111r)   c                       t          d  D                       st          d            t           fd D                       st          d            d S )Nc                 B    g | ]}t          |t          j                  S  )
isinstancer   Set).0r>   s     r'   
<listcomp>z!check_all_set.<locals>.<listcomp>k   s$    ;;;s
3	**;;;r)   z All arguments must be Sets, got c                 <    g | ]}d          j         |j         k    S )r   dtype)ra   srK   s     r'   rb   z!check_all_set.<locals>.<listcomp>n   s&    777QQ(777r)   z'All Sets must be of the same type, got )allr   )rK   s   `r'   check_all_setrh   j   s    ;;d;;;<< ECTCCDDD7777$77788 LJDJJKKKL Lr)   SetLoopindexentrydo_breakc                      e Zd Zd Zed             Zej        d             Zed             Zej        d             Zed             Zej        d             Zed             Z	e	j        d	             Z	ed
             Z
e
j        d             Z
ed             Zed             Zd ZddZej        dd            Zej        d             ZdS )_SetPayloadc                     t          ||||          }|| _        || _        || _        || _        |                    d          | _        || _        d S )Nentries)r(   _context_builder_ty_payload_get_ptr_by_name_entries_ptr)selfr    r!   r"   r#   r&   s         r'   __init__z_SetPayload.__init__w   sQ    $WgxEE00;;			r)   c                     | j         j        S Nru   maskry   s    r'   r~   z_SetPayload.mask       }!!r)   c                     || j         _        d S r|   r}   ry   r?   s     r'   r~   z_SetPayload.mask   s     #r)   c                     | j         j        S r|   ru   usedr   s    r'   r   z_SetPayload.used   r   r)   c                     || j         _        d S r|   r   r   s     r'   r   z_SetPayload.used       "r)   c                     | j         j        S r|   ru   fillr   s    r'   r   z_SetPayload.fill   r   r)   c                     || j         _        d S r|   r   r   s     r'   r   z_SetPayload.fill   r   r)   c                     | j         j        S r|   ru   fingerr   s    r'   r   z_SetPayload.finger   s    }##r)   c                     || j         _        d S r|   r   r   s     r'   r   z_SetPayload.finger   s    $r)   c                     | j         j        S r|   ru   dirtyr   s    r'   r   z_SetPayload.dirty   s    }""r)   c                     || j         _        d S r|   r   r   s     r'   r   z_SetPayload.dirty   s    #r)   c                     | j         S )z>
        A pointer to the start of the entries array.
        )rw   r   s    r'   rq   z_SetPayload.entries   s    
 }r)   c                     | j         S )zC
        A pointer to the start of the NRT-allocated area.
        )rx   r   s    r'   r#   z_SetPayload.ptr   s    
 yr)   c                     t          j        | j        | j        |          }| j                            | j        t          j        | j                  |          }|S )z)
        Get entry number *idx*.
        r   )	r   geprs   rw   rr   r   r   r+   rt   )ry   idx	entry_ptrrl   s       r'   	get_entryz_SetPayload.get_entry   sT     Kt}cBB	..t}/4~dh/G/G3< / > > r)   Fc                 	     j          j        j        } j        } j        j        }j        }|                    t          j	                  }|
                    |||fi           }	                    ||	          t          j        |d          }
t          j        |d          }t          j                  }t          j                            |                    }r*|                    d          t          j                                      d          }                    d                              d                              d          } fd}t          j        t          j        |t&                              5                      |          } ||                               ||
          }                    ||          }                    ||           d	d	d	           n# 1 swxY w Y                       |                               |          5                      |          } ||                               |          }                    ||          }                    |
                    ||                    }                    |                    ||                    }                    ||                               ||                               |           d	d	d	           n# 1 swxY w Y                                 5  rl                    |          }                              }                                        d
|          ||          }                    ||                               |           d	d	d	           n# 1 swxY w Y                                 5                      |           d	d	d	           n# 1 swxY w Y                       |                               t          j        d          d          }|                     t          j!                   |                     t          j"                   |                    |          fS )ag  
        Lookup the *item* with the given hash values in the entries.

        Return a (found, entry index) tuple:
        - If found is true, <entry index> points to the entry containing
          the item.
        - If found is false, <entry index> points to the empty entry that
          the item can be written to (only if *for_insert* is true)
              r/   zlookup.bodyzlookup.foundzlookup.not_foundz
lookup.endc                 @                        |           }|j        }                                        d|                    5   	|j        f          }                    |          5                                 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y                       t          |                    5                                 ddd           n# 1 swxY w Y   
r                    t          |                    5                                }	                                        d|          | |          }
                    |           ddd           dS # 1 swxY w Y   dS dS )zO
            Check entry *i* against the value being searched for.
            rO   N)r   r6   if_thenrQ   keybranchrS   rY   loadr=   store)irl   
entry_hasheqjbb_foundbb_not_foundr!   r    eqfn
for_insert
free_indexfree_index_sentinelrD   itemry   s        r'   check_entryz(_SetPayload._lookup.<locals>.check_entry   s    NN1%%EJ!6!6tQ
!K!KLL - - T'D%)#455__R(( - -NN8,,,- - - - - - - - - - - - - - -	- - - - - - - - - - - - - - - w!L!LMM - -|,,,- - - - - - - - - - - - - - -  1___Wgz%R%RSS 1 1Z00Aw'<'<T1FY'Z'Z'(!- -AMM!Z000	1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1s[   )B*1BB*B	B*B	B**B.1B.C;;C?C?,AFFFNrO   found)#rr   rs   r;   r~   rt   re   r4   r5   operatorr   r7   r8   r   r:   r   alloca_once_valueand_append_basic_block	for_rangeLINEAR_PROBESr   addr   r   
goto_blocklshrmulr=   rQ   position_at_endphiIntTypeadd_incomingtrue_bit	false_bit)ry   r   rD   r   intp_tr~   re   tyctxrA   rB   onefiveperturbrk   bb_bodybb_endr   r   pr   r   r   r   r!   r    r   r   r   s   ````                 @@@@@@@r'   _lookupz_SetPayload._lookup   s    --y&''44  ;;##D#..k&!$${61%% +GQ77)'*1,,q$*?*?A A 	Q"&))B-- 27<OPPJ,,];;--n==112DEE++L99	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	18 wFM(J(JKK 	$ 	$U##AKNNNAs##AQ%%AMM!U###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	w(( 	$ 	$U##AKNNN
 W%%AQ%%ACQ!5!566AT7;;q!#4#455AMM!U###MM!W%%%NN7###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$  -- 
	# 
	# ( LL''LL,,NN7#8#8qBU#V#V#$a) )a'''NN6"""
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# )) 	# 	#NN6"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	'''BJqMM7337+X6667,l;;;gll5))))sK   -A#HH #H C!L>>MMBO..O25O2P00P47P4Nc              #     K   | j         }| j        }|                    t          j                  }t          j        |d          }|                    | j        |          }t          j
        |||          5 }|                     |j                  }t          |||j                  }	|                    |	          5  t!          |j        ||j                  }
|
V  ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )zG
        Iterate over the payload's entries.  Yield a SetLoop.
        r   startrj   N)rr   rs   get_value_typer   intpr   r:   r   r~   r   r   r   rk   r9   r6   r   ri   rm   )ry   r   r    r!   r   r   size
range_looprl   is_usedloops              r'   _iteratez_SetPayload._iterate7  s     
 --''
33k&!$${{49c**wE::: 	jNN:#344E"7GUZ@@G))  Z%5U(2(;= = =


              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s7   7AD=!C*D*C.	.D1C.	2DD	Dc              #     K   | j         }| j        }|                    t          j                  }t          j        |d          }t          j        |d          }| j        }|                    d          }|                    d          }t          j
        || j                  }	|                    |           |                    |          5  |                    |	          }
|                    ||                    |
|                    }
|                    |
|	           |                     |
          }t'          |||j                  }|                    |||           ddd           n# 1 swxY w Y   |                    |           |                    |	          }
|
| _        |                     |
          V  dS )z
        Yield a random entry from the payload.  Caller must ensure the
        set isn't empty, otherwise the function won't end.
        r   r   next_entry_bodynext_entry_endN)rr   rs   r   r   r   r   r:   r~   r   r   r   r   r   r   r   r   r   r   r   r9   r6   cbranchr   )ry   r    r!   r   zeror   r~   r   r   rk   r   rl   r   s                r'   _next_entryz_SetPayload._next_entryK  s      --''
33{61%%k&!$$y
 ,,->??++,<==)'4;??w(( 	6 	6U##AT7;;q##6#677AMM!U###NN1%%E"7GUZ@@GOOGVW555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	''' LLnnQs   BE33E7:E7Fr|   )__name__
__module____qualname__rz   propertyr~   setterr   r   r   r   rq   r#   r   r   
contextlibcontextmanagerr   r   r^   r)   r'   ro   ro   u   s          " " X" 
[# # [# " " X" 
[# # [# " " X" 
[# # [# $ $ X$ ]% % ]% # # X# \$ $ \$   X   X  t* t* t* t*l    & %  %  %  %  % r)   ro   c                      e Zd Zd Zed             Zed             Zed             Zed             Zed             Z	e	j
        d             Z	d Zd	 Zd-dZd.dZd.dZd-dZd-dZd-dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd/dZd Zd Zed0d            Z ed0d             Z!e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S )1SetInstancec                     || _         || _        || _        t          ||          | _        |                    |||          | _        d S r|   )rr   rs   rt   r.   
_entrysizemake_helper_set)ry   r    r!   r"   set_vals        r'   rz   zSetInstance.__init__v  sE    ((;;''7CC			r)   c                     | j         j        S r|   )rt   re   r   s    r'   re   zSetInstance.dtype}  s    x~r)   c                     | j         }| j        }| j         j                            || j                  }t          ||| j        |          S )z/
        The _SetPayload for this set.
        )rr   rs   nrtmeminfo_datameminforo   rt   )ry   r    r!   r#   s       r'   r&   zSetInstance.payload  sD     --m,,WdlCC7GTXs;;;r)   c                 4    | j                                         S r|   )r   	_getvaluer   s    r'   r?   zSetInstance.value  s    y""$$$r)   c                     | j         j        S r|   )r   r   r   s    r'   r   zSetInstance.meminfo  s    y  r)   c                     | j         j        S r|   r   parentr   s    r'   r   zSetInstance.parent  s    yr)   c                     || j         _        d S r|   r   r   s     r'   r   zSetInstance.parent  s     	r)   c                     | j         j        S )z<
        Return the number of elements in the size.
        )r&   r   r   s    r'   get_sizezSetInstance.get_size  s     |  r)   c                 j    | j         j        r&|rt          j        nt          j        | j        _        d S d S r|   )rt   	reflectedr   r   r   r&   r   ry   vals     r'   	set_dirtyzSetInstance.set_dirty  s<    8 	P58!O!1!1g>ODL	P 	Pr)   Tc                    | j         }| j        }|j        }||_        |                     |           ||_        |j        }	t          j        |	j        d          }
|	                    |	|
          x}	|_        |
                    t          |||          d          5  |	                    |j        |
          |_        d d d            n# 1 swxY w Y   |r|                     |	           |                     d           d S )Nr   Tlikely)rr   rs   r6   incref_valuer   r   r   r:   r;   r   r   rS   r   upsizer   )ry   r&   rl   r   rD   	do_resizer    r!   old_hashr   r   s              r'   
_add_entryzSetInstance._add_entry  s7   --:
$	|k$)Q''%kk$444w|__]7GXFF$(  * * 	: 	:";;w|S99GL	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:  	KKts   !C

CCc                    | j         }| j        }|                    ||d          \  }}	|                    |          }
|                    |
          5  |                    |	          }|j        }||_        |r|                     |           ||_        |j	        }t          j        |j        d          }|                    ||          x}|_	        |                    t          |||          d          5  |                    |j        |          |_        d d d            n# 1 swxY w Y   |r|                     |           |                     d           d d d            d S # 1 swxY w Y   d S )NTr   r   r   )rr   rs   r   not_r   r   r6   r   r   r   r   r:   r;   r   rS   r   r   r   )ry   r&   r   rD   r  	do_increfr    r!   r   r   	not_foundrl   r  r   r   s                  r'   _add_keyzSetInstance._add_key  s   --??4t?<<qLL''	__Y'' 	! 	!%%a((EzHEJ (!!$'''EI<D+di++C")++dC"8"88D7<w!J!J(, ! . . > >&{{7<==> > > > > > > > > > > > > > >  "D!!!NN4   '	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s7   B&E+:!D'E+'D+	+E+.D+	//E++E/2E/c                 n   t          j        |j        j        t                    |_        |r|                     |j                   |j        }t          j        |j        d          }| j        	                    ||          x}|_        |r| 
                    |           |                     d           d S )Nr   T)r   r:   r6   r;   rV   decref_valuer   r   rs   subdownsizer   )ry   r&   rl   r  	do_decrefr   r   s          r'   _remove_entryzSetInstance._remove_entry  s    ['::
 	)ei(((|k$)Q''"m//c:::w| 	 MM$tr)   c                    | j         }| j        }|                    ||          \  }}|                    |          5  |                    |          }	|                     ||	|           d d d            n# 1 swxY w Y   |S r|   )rr   rs   r   r   r   r  )
ry   r&   r   rD   r  r    r!   r   r   rl   s
             r'   _remove_keyzSetInstance._remove_key  s    --??4++q__U## 	: 	:%%a((Ewy999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: s   -A66A:=A:c                     | j         }| j        }| j        }t          ||| j        j        |          }|                     ||||           d S r|   )rr   rs   r&   rG   rt   re   r	  )ry   r   r  r    r!   r&   rD   s          r'   r   zSetInstance.add  sL    --,7GTX^TBBgtQ	22222r)   c                     | j         }| j        }| j        }|                     ||||          }|                     ||||           dS )z`A version of .add for use inside functions following Python calling
        convention.
        N)rr   rs   r&   _pyapi_get_hash_valuer	  )ry   pyapir   r  r    r!   r&   rD   s           r'   	add_pyapizSetInstance.add_pyapi  sP     --,&&ugwEEgtQ	22222r)   c                 H   | j         j        g}t          j        }d }|g}t	          j        |g|R  }	|                    ||	|          \  }
}|                    |
d          5  |                    |	                                           ddd           n# 1 swxY w Y   |S )z=Python API compatible version of `get_hash_value()`.
        c                      t          |           S r|   )rM   )r   s    r'   wrapperz2SetInstance._pyapi_get_hash_value.<locals>.wrapper  s    ,S111r)   Fr   N)
rt   re   r   r   r   	signaturecall_jit_coder   retget_null_object)ry   r  r    r!   r   argtypesrestyr  rK   rB   is_errorretvals               r'   r  z!SetInstance._pyapi_get_hash_value  s     HN#
	2 	2 	2 vu0x000 ..wTBB&__Xe_44 	1 	1KK--//000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 s   #(BBBc                     | j         }| j        }| j        }t          ||| j        j        |          }|                    ||          \  }}|S r|   )rr   rs   r&   rG   rt   re   r   )ry   r   r    r!   r&   rD   r   r   s           r'   containszSetInstance.contains  sJ    --,7GTX^TBB??4++qr)   c                     | j         }| j        }| j        }t          ||| j        j        |          }|                     |||          }|S r|   )rr   rs   r&   rG   rt   re   r  )ry   r   r    r!   r&   rD   r   s          r'   discardzSetInstance.discard   sJ    --,7GTX^TBB  $22r)   c                 |   | j         }| j        }|                    | j        j                  }t          j        ||          }| j        }|                                5 }|	                    |j
        |           |                     ||d           d d d            n# 1 swxY w Y   |                    |          S )NF)r  )rr   rs   r   rt   re   r   alloca_oncer&   r   r   r   r  r   )ry   r    r!   ltyr   r&   rl   s          r'   popzSetInstance.pop)  s    --$$TX^44!'3//,  "" 	@eMM%)S)))w???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@
 ||C   s   4BB"%B"c                     | j         }| j        }|                    t          j                  }t          j        |t                    }|                     |           | 	                    d           d S )NT)
rr   rs   r   r   r   r   r:   MINSIZE_replace_payloadr   )ry   r    r!   r   minsizes        r'   clearzSetInstance.clear8  sb    --''
33+fg..g&&&tr)   c           	      N   | j         }| j        }| j        }|j        }|j        } t          |           ||| j        d          }|                    d||          }|                    |d          5 \  }}	|5  |	                    |          }
|
                    |                    |
          d          5  |j                            |t          d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |	5  |                     |||          }|                    |          }
|
                    |                    |
          d          5  |j                            |t          d           ddd           n# 1 swxY w Y   |j        }|                                5 }|j        }|                    ||j        |j        d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |S )z,
        Return a copy of this set.
        NrO   Tr   F)zcannot copy setr  )rr   rs   r&   r   r   r;   rt   rQ   if_else_copy_payloadr   r  	call_convreturn_user_excMemoryErrorchoose_alloc_size_allocate_payloadr   rl   r	  r   r6   )ry   r    r!   r&   r   r   otherno_deleted_entriesif_no_deleted
if_deletedoknentriesother_payloadr   rl   s                  r'   copyzSetInstance.copyA  s    --,||T

7GTXt<<$224tDD__/_== 	4*z L L((11__W\\"%5%5e_DD L L%55g{6JL L LL L L L L L L L L L L L L L LL L L L L L L L L L L L L L L  4 411'7DII,,X66__W\\"%5%5e_DD L L%55g{6JL L LL L L L L L L L L L L L L L L !&%%'' 44 JENN=%)UZ-2 # 4 4 44 4 4 4 4 4 4 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4. s   2H8A C=8"C&C=&C**C=-C*.C=1H=D	HD	H
AH!"FHFHFH5+G, H,G00H3G04H7HH	H
H	HH!Hc                    | j         }| j        }| j        }|j        }|                                5 }|j        }|                    |j        |j                  \  }}	|                    |	                    |                    5  | 
                    ||d           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                     |j                   dS )z9
        In-place intersection with *other* set.
        Fr0  N)rr   rs   r&   r   rl   r   r   r6   r   r  r  r  r   )
ry   r8  r    r!   r&   r>  r   rl   r   _s
             r'   	intersectzSetInstance.intersecth  ss    --, 	D4JE$,,UY
CCHE1e!4!455 D D""7EU"CCCD D D D D D D D D D D D D D D	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	gl#####s6   AC B)C )B-	-C 0B-	1C  CCc                    | j         }| j        }| j        }|j        }|                                5 }|j        }|                     ||j        |j        d           ddd           n# 1 swxY w Y   |                     |j	                   dS )z7
        In-place difference with *other* set.
        Fr0  N)
rr   rs   r&   r   rl   r  r   r6   r  r   )ry   r8  r    r!   r&   r>  r   rl   s           r'   
differencezSetInstance.differencez  s     --,##%% 	NJEWeiuMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N
 	gl#####s   +A((A,/A,c           	         | j         }| j        }|j        }|                                5 }|j        j        }|j        j        }| j        }|                    ||d          \  }	}
|                    |
          }|	                    |	          5 \  }}|5  | 
                    ||d           ddd           n# 1 swxY w Y   |5  |                     ||||           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                     | j        j                   dS )zA
        In-place symmetric difference with *other* set.
        Tr  Fr0  N)rr   rs   r&   r   rl   r   r6   r   r   r1  r  r  r  r   )ry   r8  r    r!   r>  r   r   rD   r&   r   r   rl   	if_commonif_not_commons                 r'   symmetric_differencez SetInstance.symmetric_difference  sF    --##%% 	<*.C
AlGsA$??HE1%%a((E'' <+EI} H H&&w&GGGH H H H H H H H H H H H H H H" < <OOGUC;;;< < < < < < < < < < < < < < << < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	dl'(((((s~   A%DDB:.D:B>>DB>DC, D,C00D3C04D7DD	D
D	DD!DFc           	         | j         }| j        }| j        }|j        }|rdnd}t          j        |t          j                  }|                    |                    ||j        |j                            5 \  }	}
|
5  |	                    t          j
        |           d d d            n# 1 swxY w Y   |	5  |                                5 }|j        }|                    |j        |j                  \  }}|                    |                    |                    5  |	                    t          j
        |           |                                 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    |          S )Nr[   <=)rr   rs   r&   r   r   r   r1  rQ   r   r   r   r   rl   r   r   r6   r   r  rm   r   )ry   r8  strictr    r!   r&   r>  cmp_opres
if_smaller	if_largerr   rl   r   rA  s                  r'   issubsetzSetInstance.issubset  s   --,(D'1ABB__!!&',8JKK  	((*i 6 6g/5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6  ( (%%'' (4 JE,44UY
KKHE1 e)<)<== ( (g&7===( ( ( ( ( ( ( ( ( ( ( ( ( ( (( ( ( ( ( ( ( ( ( ( ( ( ( ( (( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( ||C   s   6F$<!B)F$)B-	-F$0B-	1F$6FAE65E	E6E##E6&E#'E6*F6E::F=E:>FF$F	F$F	F$$F(+F(c                   	 | j         }| j        | j        }|j        }t          j        t          j                  		fd}                                        d|j        |j                            5 \  }}|5   |||           d d d            n# 1 swxY w Y   |5   |||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   	                    	          S )Nc                 x   |                                  5 }|j        }|                    |j        |j                  \  }}                    |          5                      t          j                   |	                                 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r|   )
r   rl   r   r   r6   r   r   r   r   rm   )smallerlargerr   rl   r   rA  r!   rM  s         r'   checkz%SetInstance.isdisjoint.<locals>.check  s#   !!## $t
!>>%)UZ@@q__U++ $ $MM'"3S999MMOOO$ $ $ $ $ $ $ $ $ $ $ $ $ $ $$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s6   A B/5BB/B	B/B	B//B36B3>)
rr   rs   r&   r   r   r   r1  rQ   r   r   )
ry   r8  r    r&   r>  rU  rO  	otherwiser!   rM  s
           @@r'   
isdisjointzSetInstance.isdisjoint  s   --,'1ABB	$ 	$ 	$ 	$ 	$ 	$ __!!#w|]5GHH  
	.')Y . .mW---. . . . . . . . . . . . . . .  . .g}---. . . . . . . . . . . . . . .
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. 
	. ||C   sZ   8C>BCB	CB	C$B=1C=C	CC	CCCc           	      |   | j         }| j        }| j        }|j        }t          j        |t          j                  }|                    |                    d|j        |j                            5 \  }}|5  |	                                5 }	|	j
        }
|                    |
j        |
j                  \  }}|                    |                    |                    5  |                    t          j        |           |	                                 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |5  |                    t          j        |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                    |          S )NrO   )rr   rs   r&   r   r   r   r1  rQ   r   r   rl   r   r   r6   r   r  r   r   rm   r   )ry   r8  r    r!   r&   r>  rM  if_same_sizerW  r   rl   r   rA  s                r'   equalszSetInstance.equals  s   --,'1ABB__!!$m6HII  	6*,	 ( (%%'' (4 JE,44UY
KKHE1 e)<)<== ( (g&7===( ( ( ( ( ( ( ( ( ( ( ( ( ( (( ( ( ( ( ( ( ( ( ( ( ( ( ( (( ( ( ( ( ( ( ( ( ( ( ( ( ( (  6 6g/5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 ||C   s   0F6EAD65D	D6D##D6&D#'D6*E6D::E=D:>EFE	FE	F!F;FF	FF	FF"%F"Nc                 J   |                     t          j                  }|t          j        |t
                    }nAt          |t                    rt          j        ||          }|                     |||          } | |||d          }|	                    |          }||fS )z
        Allocate a SetInstance with its storage.
        Return a (ok, instance) tuple where *ok* is a LLVM boolean and
        *instance* is a SetInstance object (the object's contents are
        only valid when *ok* is true).
        N)
r   r   r   r   r:   r+  r_   intr6  r7  )	clsr    r!   r"   nitemsr   r=  ry   r<  s	            r'   allocate_exzSetInstance.allocate_ex  s     ''
33>{6733HH&#&& 5VV44,,WgvFFHs7GXt44##H--4xr)   c                    |                      ||||          \  }}|                    |                    |          d          5  |j                            |t
          d           ddd           n# 1 swxY w Y   |S )z
        Allocate a SetInstance with its storage.  Same as allocate_ex(),
        but return an initialized *instance*.  If allocation failed,
        control is transferred to the caller using the target's current
        call convention.
        Fr   )zcannot allocate setN)r`  r   r  r3  r4  r5  )r^  r    r!   r"   r_  r<  ry   s          r'   allocatezSetInstance.allocate  s     ??7GXvFFD__W\\"--e_<< 	H 	H--g{.FH H H	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H s   "A44A8;A8c                      | |||d          }||j         _        |                    t          j                  |j         _        |j                            |||j                   |S )z
        Allocate a new set instance pointing to an existing payload
        (a meminfo pointer).
        Note the parent field has to be filled by the caller.
        N)	r   r   get_constant_nullr   pyobjectr   r   increfr?   )r^  r    r!   r"   r   ry   s         r'   from_meminfozSetInstance.from_meminfo  s^     s7GXt44#	"44U^DD	7Hdj999r)   c                 R   |j         }t          j        |d          }t          j        |t                    }|                    ||          }t          j        ||          }|                    d          }	|                    d          }
|                    |	           |	                    |	          5  |
                    |          }|                    d||          }|                    |d          5  |                    |
           ddd           n# 1 swxY w Y   |                    ||          }|                    ||           |                    |	           ddd           n# 1 swxY w Y   |                    |
           |
                    |          S )zT
        Choose a suitable number of entries for the given number of items.
        r   calcsize.bodycalcsize.end>=Fr   N)r;   r   r:   r+  shlr   r   r   r   r   r   rQ   r   r   r   )r^  r    r!   r_  r   r   r-  min_entriessize_pr   r   r   is_large_enough	next_sizes                 r'   r6  zSetInstance.choose_alloc_size$  s   
 k&!$$+fg.. kk&#..*7G<<,,_==++N;;w(( 	$ 	$<<''D%33D$LLO?? ' 'v&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' 'D#..IMM)V,,,NN7###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	'''||F###s8   6AE4:DE4D 	 E4#D 	$AE44E8;E8c           	      &   | j         }| j        }|j        }t          j        |d          }t          j        |d          }| j        }|                    ||          }|                    |j        |          }	|	                    d||	          }
|
                    |
d          5  t          j        ||	          }|                    d          }|                    d          }|                    |           |                    |          5  |                    |          }|                    ||          }|                    ||           |	                    d||          }|                    |||           ddd           n# 1 swxY w Y   |                    |           |                    |          }t(          r|                    |d	||	||           |                     ||d
           ddd           dS # 1 swxY w Y   dS )zs
        When adding to the set, ensure it is properly sized for the given
        number of used entries.
        r      rk  Fr   ri  rj  NzKupsize to %zd items: current size = %zd, min entries = %zd, new size = %zd
zcannot grow set)rr   rs   r;   r   r:   r&   rl  r   r~   rQ   r   r   r   r   r   r   r   r   r   r   DEBUG_ALLOCSprintf_resize)ry   r_  r    r!   r   r   twor&   rm  r   need_resize
new_size_pr   r   new_sizeis_too_smalls                   r'   r   zSetInstance.upsizeC  s   
 --k&!$$k&!$$, kk&#..{{7<--++D+tDD__[_77 	? 	? 27DAAJ00AAG//??FNN7#####G,, ? ?"<<
33";;x55h
333&44T;QQgv>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ##F+++||J//H Dw E%t[(D D D LL(,=>>>3	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s9   &A*HA0F HF	HF	A%HH
H
c           	         | j         }| j        }|j        }t          j        |d          }t          j        |d          }t          j        |t
                    }| j        }|                    ||          }	|                    |	                    d|	|          |	|          }	|                    |	|          }
|
                    |j        |          }|                    |	                    d|
|          |	                    d||                    }|                    |d          5  t          j        ||          }|                    d          }|                    d	          }|                    |           |                    |          5  |                    |          }|                    ||          }|	                    d
|	|          }|                    |          5  |                    |           ddd           n# 1 swxY w Y   |                    ||           |                    |           ddd           n# 1 swxY w Y   |                    |           |                    |          }t.          r|                    |d|||	|           |                     ||d           ddd           dS # 1 swxY w Y   dS )zw
        When removing from the set, ensure it is properly sized for the given
        number of used entries.
        r   rr  rk  rJ  r[   Fr   ri  rj  rV  NzMdownsize to %zd items: current size = %zd, min entries = %zd, new size = %zd
zcannot shrink set)rr   rs   r;   r   r:   r+  r&   rl  r=   rQ   r   r~   r   r   r   r   r   r   r   r   r   r   r   rs  rt  ru  )ry   r_  r    r!   r   r   rv  r-  r&   rm  max_sizer   rw  rx  r   r   ry  rz  s                     r'   r  zSetInstance.downsizeq  s   
 --k&!$$k&!$$+fg.., kk&#..nnW%:%:4g%V%V%0'; ; ;;{C00{{7<--ll!!$$77!!#w557 7 __[_77  	A  	A 27DAAJ00AAG//??FNN7#####G,, 	( 	("<<
33"<<#66&44S+xPP__\22 + +NN6***+ + + + + + + + + + + + + + +h
333w'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( ##F+++ ||J//H  Dw E%t[(D D D LL(,?@@@A 	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	A  	As]   +A*KAI-HIHIH.IKI	KI	A%KKKc                    | j         }| j        }|}|                     |d          }|                    |                    |          d          5  |j                            |t          |f           ddd           n# 1 swxY w Y   | j        }|	                                5 }|j
        }	|                     ||	j        |	j        dd           ddd           n# 1 swxY w Y   |                     |j                   dS )zw
        Resize the payload to the given number of entries.

        CAUTION: *nentries* must be a power of 2!
        TreallocFr   N)r  r  )rr   rs   r7  r   r  r3  r4  r5  r&   r   rl   r	  r   r6   _free_payloadr#   )
ry   r&   r=  errmsgr    r!   old_payloadr<  r   rl   s
             r'   ru  zSetInstance._resize  s    -- ##Hd#;;__W\\"--e_<< 	9 	9--g{/5i9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 ,!!## 	<tJEMM'59ej$)U  < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<
 	;?+++++s$   #BBB',CC#&C#c                    | j         }| j        }| j                                        5 }|j        }|                     |j                   ddd           n# 1 swxY w Y   |                     | j        j                   | 	                    |d          }|
                    |                    |          d          5  |j                            |t          d           ddd           dS # 1 swxY w Y   dS )z
        Replace the payload with a new empty payload with the given number
        of entries.

        CAUTION: *nentries* must be a power of 2!
        NTr~  Fr   )zcannot reallocate set)rr   rs   r&   r   rl   r  r   r  r#   r7  r   r  r3  r4  r5  )ry   r=  r    r!   r   rl   r<  s          r'   r,  zSetInstance._replace_payload  s    -- \""$$ 	)JEei(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)
 	4<+,,,##Hd#;;__W\\"--e_<< 	J 	J--g{.HJ J J	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Js#   "AAA"C00C47C4c           
         | j         }| j        }t          j        |t          j                  }|                    t          j                  }t          j	        |d          }t          j	        |d          }|
                    t          j        | j                            }	|                    |	          }
| j        }|
|z  }
t          j        ||t          j	        ||          t          j	        ||
                    \  }}|                    |d          5  |                    t          j        |           ddd           n# 1 swxY w Y   |                    |                    |          d          5  |r?| j        j        }|j                            |||          }t          j        ||          }nj|                     ||j                  }|j                            |||                    |t          j                            }t          j        ||          }|                    |d          5 \  }}|5  |                    t          j        |           ddd           n# 1 swxY w Y   |5  |s5|| j        _        |                    t          j                   | j        _!        | j"        }t          j#        ||j$        |d           ||_%        ||_&        ||_'        |(                    ||          }||_)        tT          r|+                    |d	||j$        |           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                    |          S )
z
        Allocate and initialize payload for the given number of entries.
        If *realloc* is True, the existing meminfo is reused.

        CAUTION: *nentries* must be a power of 2!
        r   r   Fr   NT)r      .allocated %zd bytes for set at %p: mask = %zd
),rr   rs   r   r   r   r   r   r   r   r:   r   r   rt   r,   r   muladd_with_overflowr   r   r   r   r   r   r   meminfo_varsize_alloc_uncheckedis_null	_imp_dtormodule"meminfo_new_varsize_dtor_uncheckedr   	voidptr_tr1  rd  re  r   r&   memsetr#   r   r   r   r  r~   rs  rt  )ry   r=  r  r    r!   r<  r   r   r   r$   payload_size
entry_size	allocsizeovfr   r#   alloc_okdtorif_errorif_okr&   new_masks                         r'   r7  zSetInstance._allocate_payload  s    --&w0@AA''
33{61%%k&!$$,,U-=dh-G-GHH--l;;_

" !5gx68k&*6U6U68k&,6W6WY Y	3 __S_// 	1 	1MM'+R000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 __W\\"--d_;; "	I "	I =)+kAA'BI=F B H H #?7C88 ~~gw~>>!+HHYg>O(P(PR R"?7G<<(- ! / / I2C8U 9 9MM'"3R8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 I I" U,3	)+2+D+DU^+T+T	("lGN7GKDIII#'GL#'GL%)GN&{{8S99H#+GL# Iw'X'0'+xI I II I I I I I I I I I I I I I I	I I I I I I I I I I I I I I I"	I "	I "	I "	I "	I "	I "	I "	I "	I "	I "	I "	I "	I "	I "	IH ||Bs   !EEE=CM, M!I3'M3I77M:I7;M B2L>2M>MMMM	M,M	M,M	M,,M03M0c                 \    | j         j                            | j        | j        |           dS )z9
        Free an allocated old payload at *ptr*.
        N)rr   r   meminfo_varsize_freers   r   )ry   r#   s     r'   r  zSetInstance._free_payload"  s+     	..t}dlCPPPPPr)   c           
         | j         }| j        }t          j        |t          j                  }|                    t          j                  }t          j	        |d          }t          j	        |d          }|
                    t          j        | j                            }|                    |          }	| j        }
|	|
z  }	|j        }|                    ||          }|                    t          j	        ||	          |                    t          j	        ||
          |                    }|                    |                    |          d          5  |                     ||j                  }|j                            |||                    |t          j                            }t          j        ||          }|                    |d          5 \  }}|5  |                    t          j        |           ddd           n# 1 swxY w Y   |5  || j        _        | j         }|j!        |_!        |j"        |_"        ||_#        ||_        t          j$        ||j%        |j%        ||
           |&                                5 }| '                    |j(        j)                   ddd           n# 1 swxY w Y   tT          r|+                    |d||j,        |           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                    |          S )z7
        Raw-copy the given payload into self.
        r   r   Tr   FNr  )-rr   rs   r   r   r   r   r   r   r   r:   r   r   rt   r,   r   r~   r   r   r   r   r  r  r   r  r   r  r  r1  r   r   r   r   r&   r   r   r   
raw_memcpyrq   r   r   rl   r   rs  rt  r#   )ry   src_payloadr    r!   r<  r   r   r   r$   r  r  r~   r=  r  r  r   r  r  r  r&   r   s                        r'   r2  zSetInstance._copy_payload(  s^    --&w0@AA''
33{61%%k&!$$,,U-=dh-G-GHH--l;;_

";;sD))
 KKFL A A 'BK
,K,K,4!6 !67 7	 __W\\"--d_;;  	E  	E>>'7>::DkDDGOOD':K$L$LN NGw88H%88 E<MXu 9 9MM'"3R8889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 E E(/DI%"lG#.#3GL#.#3GL%)GN#'GL
 &w'2':H'13 3 3
 %--// :4))$*.999: : : : : : : : : : : : : : : $ Ew'X'0'+tE E E)E E E E E E E E E E E E E E EE E E E E E E E E E E E E E E 	E  	E  	E  	E  	E  	E  	E  	E  	E  	E  	E  	E  	E  	E  	ED ||Bs   BL#L#!HLHLHLA0K5 J9	-K59J==K5 J=(K5)L5K99L<K9=L L#L	L#L	L##L'*L'c                    t           j        }|                    t          j                  }t          j        t          j                    |||g          }d| j        j	         }t          j
        |||          }|j        rd|_        t          j        |                                          }t          ||| j        |j        d                   }	|	                                5 }
|
j        }|j                            || j        j	        |j                   ddd           n# 1 swxY w Y   |                                 |S )z Define the dtor for set
        z
.dtor.set.)namelinkonce_odrr   N)r   r  r   r   size_tr   FunctionTypeVoidTypert   re   get_or_insert_functionis_declarationlinkage	IRBuilderr   ro   rK   r   rl   r   decrefr   ret_void)ry   r    r  	llvoidptrllsize_trA   fnamerC   r!   r&   r   rl   s               r'   r  zSetInstance._imp_dtori  sk    %	((66KMM),
 

 .TX^--+FDuEEE 		'BJl2#8#8#:#:;;G!'7DHbgajIIG!!## Gt
""7DHNEIFFFG G G G G G G G G G G G G G G 	s   %3D$$D(+D(c                 f    | j         j                            | j        | j        j        |           dS )z Incref an element value
        N)rr   r   rf  rs   rt   re   r   s     r'   r   zSetInstance.incref_value  -     	  DDDDDr)   c                 f    | j         j                            | j        | j        j        |           dS )z Decref an element value
        N)rr   r   r  rs   rt   re   r   s     r'   r  zSetInstance.decref_value  r  r)   )T)TTr   r|   ).r   r   r   rz   r   re   r&   r?   r   r   r   r   r   r  r	  r  r  r   r  r  r#  r%  r)  r.  r?  rB  rD  rH  rP  rX  r[  classmethodr`  rb  rg  r6  r   r  ru  r,  r7  r  r2  r  r   r  r^   r)   r'   r   r   t  sG       D D D   X 	< 	< X	< % % X% ! ! X!     X  ]! ! ]!! ! !P P P   *! ! ! !8   
 
 
 
3 3 3 3	3 	3 	3 	3  $    ! ! !  % % %N$ $ $$$ $ $ ) ) )0! ! ! !4! ! !>! ! !0    [(    [   [ $ $ [$<,? ,? ,?\:A :A :Ax, , ,6J J J.A  A  A  A FQ Q Q?  ?  ? B  8E E E
E E E E Er)   r   c                       e Zd Zd Zed             Zed             Zed             Zed             Z	e	j
        d             Z	d ZdS )	SetIterInstancec                     || _         || _        || _        |                    |||          | _        | j         j                            || j                  }t          ||| j        j	        |          | _
        d S r|   )rr   rs   rt   r   _iterr   r   r   ro   	containerru   )ry   r    r!   	iter_typeiter_valr#   s         r'   rz   zSetIterInstance.__init__  sj    (()XFF
m,,WdlCC#GWdh6H#NNr)   c                     t          |||j        |          } | |||d           }|                    t          j        d          }t          j        ||          |j        _        |j	        |j        _	        |S rJ   )
r   r  get_constantr   r   r   r   r  rk   r   )r^  r    r!   r  r   set_instry   rk   s           r'   from_setzSetIterInstance.from_set  sm    w1DgNNs7GY55$$UZ33"4WeDD
%-
r)   c                 4    | j                                         S r|   )r  r   r   s    r'   r?   zSetIterInstance.value  s    z##%%%r)   c                     | j         j        S r|   )r  r   r   s    r'   r   zSetIterInstance.meminfo  s    z!!r)   c                 J    | j                             | j        j                  S r|   )rs   r   r  rk   r   s    r'   rk   zSetIterInstance.index  s    }!!$*"2333r)   c                 P    | j                             || j        j                   d S r|   )rs   r   r  rk   r   s     r'   rk   zSetIterInstance.index  s%    E4:#344444r)   c                    | j         }| j        }t          j        |j        d          }|                                 |                    |          5 }|j        }|                                 |	                    |j
                   | j                            |j         |          | _         |                                 d d d            d S # 1 swxY w Y   d S )Nr   r   )rk   ru   r   r:   r;   set_exhaustedr   rl   	set_validyield_r   rs   r   rm   )ry   resultrk   r&   r   r   rl   s          r'   iternextzSetIterInstance.iternext  s   
-k%*a((E** 	dJEMM%)$$$**4:s;;DJMMOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A/CCCN)r   r   r   rz   r  r  r   r?   r   rk   r   r  r^   r)   r'   r  r    s        O O O   [ & & X& " " X" 4 4 X4 \5 5 \5    r)   r  c           	      
   t          |          }t                              | |||          }|dk    rt          j        ||          }t          j        ||          }|                     t          j        |          }t          j	        ||          5 }	|
                    t          j        ||d|	j                            }
|                    |
           ddd           n# 1 swxY w Y   t          | |||j                  S )zD
    Build a set of the given type, containing the given items.
    r   N)lenr   rb  r   
pack_arrayr   r  r   r   r   r   r   rk   r   r   r?   )r    r!   r"   itemsr_  instarray	array_ptrcountr   r   s              r'   	build_setr    s    ZZF(FCCDzz "7E22-gu==	$$UZ88w.. 	$<<GY4: N NOODHHTNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GWh
CCCs   AC##C'*C'c                 v    |j         }t                              | ||          }t          | |||j                  S r|   )return_typer   rb  r   r?   )r    r!   rB   rK   r"   r  s         r'   set_empty_constructorr    s6    H(;;DGWh
CCCr)   c                    |j         }|j        \  }|\  }t          | |||          }t                              | |||          }t          | |||          5 }	|                    |	j                   | j        	                    ||j
        |	j                   d d d            n# 1 swxY w Y   t          | |||j                  S r|   )r  rK   r   r   rb  r   r   r?   r   r  re   r   )
r    r!   rB   rK   r"   
items_typer  nr  r   s
             r'   set_constructorr    s   H(KJFE 	':u55A(A>>D	'7J	6	6 @$7HNDJ???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ GWh
CCCs   AB##B'*B'c                 p    t          | ||j        d         |d                   }|                                S rJ   )r   rK   r   r    r!   rB   rK   r  s        r'   set_lenr    s-    w!d1g>>D==??r)   c                 ~    t          | ||j        d         |d                   }|                    |d                   S Nr   r   )r   rK   r#  r  s        r'   in_setr    s5    w!d1g>>D==a!!!r)   getiterc                     t                               | ||j        |d                   }t          | ||j        |j                  S rJ   )r  r  r  r   r?   r  s        r'   getiter_setr    s9    ##GWcotAwOODWgs
KKKr)   r  c                 v    t          | ||j        d         |d                   }|                    |           d S rJ   )r  rK   r  )r    r!   rB   rK   r  r  s         r'   iternext_listiterr  	  s9     7GSXa[$q'BBDMM&r)   zset.addc                     t          | ||j        d         |d                   }|d         }|                    |           |                                 S r  )r   rK   r   get_dummy_valuer    r!   rB   rK   r  r   s         r'   set_addr    sI    w!d1g>>D7DHHTNNN""$$$r)   c                 :    t          j        ||          }d }||fS )Nc                     t          | ||j        d         |d                   }|d         }|                    |           |                                 S r  )r   rK   r%  r  r  s         r'   set_discardz!_set_discard.<locals>.set_discard"  sL    7GSXa[$q'BBAwT&&(((r)   r   none)r@   rf   r   rB   r  s        r'   _set_discardr    s/    
*Q

C) ) ) r)   r%  c                     d S )Nc                 "    t          | |          S r|   )r  rf   r   s     r'   <lambda>z ol_set_discard.<locals>.<lambda>.  s    <400 r)   r^   r  s     r'   ol_set_discardr  ,  s    000r)   c                 :    |                     |          }d }||fS )Nc                 N   t          | ||j        d         |d                   }|j        j        }|                    t          j        ||          d          5  | j                            |t          d           d d d            n# 1 swxY w Y   |
                                S )Nr   Fr   )zset.pop(): empty set)r   rK   r&   r   r   r   r  r3  r4  KeyErrorr)  )r    r!   rB   rK   r  r   s         r'   set_popz_set_pop.<locals>.set_pop5  s    7GSXa[$q'BB| __W_Wd;;E_JJ 	G 	G--gx,EG G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G xxzzs   "BBBrd   )r@   rf   rB   r  s       r'   _set_popr  1  s,    
''!**C   <r)   r)  c                     d S )Nc                      t          |           S r|   )r  rf   s    r'   r  zol_set_pop.<locals>.<lambda>C  s    Xa[[ r)   r^   r  s    r'   
ol_set_popr  A  s       r)   c                 :    t          j        ||          }d }||fS )Nc                 p   t          | ||j        d         |d                   }|d         }|                    |          }|                    |                    |          d          5  | j                            |t          d           d d d            n# 1 swxY w Y   |                                 S )Nr   r   Fr   )zset.remove(): key not in set)	r   rK   r%  r   r  r3  r4  r  r  )r    r!   rB   rK   r  r   r   s          r'   
set_removez_set_remove.<locals>.set_removeJ  s    7GSXa[$q'BBAwT""__W\\%00_?? 	O 	O--gx,MO O O	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O &&(((s   +"BB Br  )r@   rf   r   rB   r  s        r'   _set_remover  F  s.    
*Q

C) ) ) 
?r)   removec                 "    | j         |k    rd S d S )Nc                 "    t          | |          S r|   )r  r  s     r'   r  zol_set_remove.<locals>.<lambda>Z  s    {1d33 r)   rd   r  s     r'   ol_set_remover  W  s    w$333 r)   c                 8    t          j        |          }d }||fS )Nc                     t          | ||j        d         |d                   }|                                 |                                 S rJ   )r   rK   r.  r  r  s        r'   	set_clearz_set_clear.<locals>.set_clearc  s>    7GSXa[$q'BB

&&(((r)   r  )r@   rf   rB   r  s       r'   
_set_clearr  _  s*    
*Q--C) ) )
 	>r)   r.  c                     d S )Nc                      t          |           S r|   )r  r  s    r'   r  zol_set_clear.<locals>.<lambda>m  s    Z]] r)   r^   r  s    r'   ol_set_clearr  k  s    """r)   c                 &     ||          }d }||fS )Nc                     t          | ||j        d         |d                   }|                                }t          | ||j        |j                  S rJ   )r   rK   r?  r   r  r?   r    r!   rB   rK   r  r8  s         r'   set_copyz_set_copy.<locals>.set_copyt  sD    7GSXa[$q'BB		#/5;OOOr)   r^   )r@   rf   rB   r
  s       r'   	_set_copyr  p  s-    
!A$$CP P P
 =r)   r?  c                     d S )Nc                      t          |           S r|   )r  r  s    r'   r  zol_set_copy.<locals>.<lambda>~  s    Yq\\ r)   r^   r  s    r'   ol_set_copyr  |  s    !!!r)   c                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |           |                                 S r  )r   rK   rD  r  r	  s         r'   set_difference_updater    s`    w!d1g>>D#(1+tAw??EOOE""$$$r)   c                 >    t          j        ||          }|t          fS r|   )r   r  r  r@   abrB   s       r'   _set_difference_updater    s    
*Q

C%%%r)   difference_updatec                 (    t          | |           d S )Nc                 "    t          | |          S r|   )r  r  r  s     r'   r  z,set_difference_update_impl.<locals>.<lambda>  s    .q!44 r)   rh   r  s     r'   set_difference_update_implr    s    !Q444r)   c                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |           |                                 S r  )r   rK   rB  r  r	  s         r'   set_intersection_updater    s`    w!d1g>>D#(1+tAw??ENN5""$$$r)   c                 >    t          j        ||          }|t          fS r|   )r   r  r  r  s       r'   _set_intersection_updater    s    
*Q

C'''r)   intersection_updatec                 (    t          | |           d S )Nc                 "    t          | |          S r|   )r  r  s     r'   r  z.set_intersection_update_impl.<locals>.<lambda>  s    0A66 r)   r  r  s     r'   set_intersection_update_implr#    s    !Q666r)   c                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |           |                                 S r  )r   rK   rH  r  r	  s         r'   set_symmetric_difference_updater%    sb    w!d1g>>D#(1+tAw??Ee$$$""$$$r)   c                 >    t          j        ||          }|t          fS r|   )r   r  r%  r  s       r'    _set_symmetric_difference_updater'    s    
*Q

C///r)   symmetric_difference_updatec                 (    t          | |           d S )Nc                 "    t          | |          S r|   )r'  r  s     r'   r  z6set_symmetric_difference_update_impl.<locals>.<lambda>  s    8A>> r)   r  r  s     r'   $set_symmetric_difference_update_implr+    s    !Q>>>r)   z
set.updatec                    t          | ||j        d         |d                   }|j        d         }|d         }t          | |||          }|5|                    |j        j        |          }|                    |           t          | |||          5 }	|                     ||	j	        |j
        |j
                  }
|                    |
           | j                            ||j
        |	j	                   d d d            n# 1 swxY w Y   ||                    |j        j                   |                                 S r  )r   rK   r   r   r&   r   r   r   castr?   re   r   r  r  r  )r    r!   rB   rK   r  r  r  r  ry  r   casteds              r'   
set_updater/    sp   w!d1g>>D!JGE 	':u55A};;t|0!44H	'7J	6	6 	B$ gtz:3CTZPP
 	7J$4djAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	}dl'(((""$$$s   A#DD
Dc                 b    t           fd            t          |           fd            }d S )Nc                 .     |||          }fd}||fS )Nc                     |j         |j        d         k    sJ  | |||           t          | ||j        d         |d                   S rJ   )r  rK   r   )r    r!   rB   rK   rL   s       r'   codegenz>gen_operator_impl.<locals>._set_operator_intr.<locals>.codegen  sP    ?chqk1111D'3---$Wgsx{DGLLLr)   r^   )r@   r  r  rB   r3  rL   s        r'   _set_operator_intrz-gen_operator_impl.<locals>._set_operator_intr  s<    a1gg	M 	M 	M 	M 	M G|r)   c                 .    t          | |           fdS )Nc                      | |          S r|   r^   r  r  r4  s     r'   r  z=gen_operator_impl.<locals>._ol_set_operator.<locals>.<lambda>  s    ..q!44 r)   r  r7  s     r'   _ol_set_operatorz+gen_operator_impl.<locals>._ol_set_operator  s"    a44444r)   )r   r   )oprL   r8  r4  s    ` @r'   gen_operator_implr:    s\        Y b\\5 5 5 5 \5 5 5r)   rD  c                 ,    t          | |           d }|S )Nc                 X    |                                  }|                    |           |S r|   )r?  r  r  r  rf   s      r'   difference_implz,impl_set_difference.<locals>.difference_impl  s(    FFHH	Ar)   r  )r  r  r>  s      r'   impl_set_differencer?    s+     !Q  
 r)   intersectionc                 ,    t          | |           d }|S )Nc                     t          |           t          |          k     r+|                                 }|                    |           |S |                                }|                    |            |S r|   )r  r?  r   r=  s      r'   intersection_implz+set_intersection.<locals>.intersection_impl  sc    q66CFF??A!!!$$$HA!!!$$$Hr)   r  )r  r  rC  s      r'   set_intersectionrD    s+     !Q   r)   rH  c                 ,    t          | |           d }|S )Nc                     t          |           t          |          k    r+|                                 }|                    |           |S |                                }|                    |            |S r|   )r  r?  r(  r=  s      r'   symmetric_difference_implz;set_symmetric_difference.<locals>.symmetric_difference_impl  sc    q66CFF??A))!,,,HA))!,,,Hr)   r  )r  r  rG  s      r'   set_symmetric_differencerH    s+     !Q   %$r)   unionc                 ,    t          | |           d }|S )Nc                     t          |           t          |          k    r+|                                 }|                    |           |S |                                }|                    |            |S r|   )r  r?  updater=  s      r'   
union_implzset_union.<locals>.union_impl(  sY    q66CFF??AHHQKKKHAHHQKKKHr)   r  )r  r  rM  s      r'   	set_unionrN  #  s+     !Q   r)   c                 :    t          j        ||          }d }||fS )Nc                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |          S r  )r   rK   rX  r	  s         r'   r3  z _set_isdisjoint.<locals>.codegen;  sN    7GSXa[$q'BBGWchqk47CCu%%%r)   r   booleanr@   r  r  rB   r3  s        r'   _set_isdisjointrT  7  s.    
-1

C& & & <r)   rX  c                 (    t          | |           d S )Nc                 "    t          | |          S r|   )rT  r  s     r'   r  z set_isdisjoint.<locals>.<lambda>H  s    1-- r)   r  r  s     r'   set_isdisjointrW  D  s    !Q---r)   c                 :    t          j        ||          }d }||fS )Nc                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |          S r  r   rK   rP  r	  s         r'   r3  z_set_issubset.<locals>.codegenO  sN    7GSXa[$q'BBGWchqk47CC}}U###r)   rQ  rS  s        r'   _set_issubsetr[  K  s.    
-1

C$ $ $ <r)   rP  c                 (    t          | |           d S )Nc                 "    t          | |          S r|   )r[  r  s     r'   r  zset_issubset.<locals>.<lambda>\  s    a++ r)   r  r  s     r'   set_issubsetr^  W  s     !Q+++r)   
issupersetc                 ,    t          | |           d }|S )Nc                 ,    |                     |           S r|   )rP  r  s     r'   superset_implz%set_issuperset.<locals>.superset_impld  s    zz!}}r)   r  )r  r  rb  s      r'   set_issupersetrc  _  s+     !Q   r)   c                 :    t          j        ||          }d }||fS )Nc                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |          S r  )r   rK   r[  r	  s         r'   r3  z_set_eq.<locals>.codegenm  sN    7GSXa[$q'BBGWchqk47CC{{5!!!r)   rQ  rS  s        r'   _set_eqrf  i  s.    
-1

C" " " <r)   c                 (    t          | |           d S )Nc                 "    t          | |          S r|   )rf  r  s     r'   r  zset_eq.<locals>.<lambda>y      1 r)   r  r  s     r'   set_eqrj  u      !Q%%%r)   c                 ,    t          | |           d }|S )Nc                     | |k     S r|   r^   r  s     r'   ne_implzset_ne.<locals>.ne_impl  s    6zr)   r  )r  r  rn  s      r'   set_nero  {  s(    !Q   Nr)   c                 :    t          j        ||          }d }||fS )Nc                     t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |d          S )Nr   r   T)rK  rZ  r	  s         r'   r3  z_set_lt.<locals>.codegen  sR    7GSXa[$q'BBGWchqk47CC}}U4}000r)   rQ  rS  s        r'   _set_ltrr    s.    
-1

C1 1 1 <r)   c                 (    t          | |           d S )Nc                 "    t          | |          S r|   )rr  r  s     r'   r  zset_lt.<locals>.<lambda>  ri  r)   r  r  s     r'   set_ltru    rk  r)   c                 ,    t          | |           d }|S )Nc                     || k     S r|   r^   r  s     r'   gt_implzset_gt.<locals>.gt_impl  s    1ur)   r  )r  r  rx  s      r'   set_gtry    s(    !Q   Nr)   c                 P   t          | ||j        d         |d                   }t          | ||j        d         |d                   }|                    |j        t          j                  }|                    |j        t          j                  }|                    d||          S )Nr   r   rO   )r   rK   ptrtointr   r   r   icmp_signed)r    r!   rB   rK   r  r  mambs           r'   set_isr    s    GWchqk47;;AGWchqk47;;A			!)W^	4	4B			!)W^	4	4BtR,,,r)   c                 *    |j         |j         k    sJ |S r|   rd   )r    r!   fromtytotyr   s        r'   
set_to_setr    s     <4:%%%%Jr)   )}__doc__collectionsr   mathr   	functoolsr   llvmliter   
numba.corer   r   r   numba.core.imputilsr   r	   r
   r   r   r   r   r   r   
numba.miscr   numba.cpythonr   numba.core.errorsr   r   numba.core.extendingr   r   r   r(   r.   rP   rV   r<   r+  r   rs  rG   rM   rS   rY   r9   rh   
namedtupleri   objectro   r   r  r  setr  IterableTyper  r  r`   r  r#  Anyr  r  SetIterBORROWEDr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r%  r'  r+  r/  r:  iandiorisubixorop_op_implr  r?  r   rD  xorrH  or_rN  rT  rW  r[  ler^  gerc  rf  r   rj  nero  rr  ltru  gtry  is_r  r  r^   r)   r'   <module>r     s/
   
           % % % % % %       - - - - - - - - - -A A A A A A A A A A A A A A A A A A A A A A !           ! ! ! ! ! ! : : : : : : : : E E E E E E E E E EH H H( ( ( 	
  . . .   1 1 13 3 32 2 2L L L !+
 ,J
K
K|  |  |  |  | & |  |  | ~YE YE YE YE YE& YE YE YEx0 0 0 0 0f 0 0 0lD D D, sD D D
 sE&''D D ('D. sEI   x %)UY77" " 87" y%)$$L L %$L z5=))w    !  *) y%)UY//% % 0/% 
 
 
 I&&1 1 '&1    E""! ! #"!     H%%4 4 &%4    G$$# # %$#    F##" " $#"% % % & & &
 /005 5 105
% % % ( ( (
 1227 7 327
% % % 0 0 0
 9::? ? ;:?
 |UY(:;;% % <;%:5 5 5" ]+,\:])*]34	 $ $LC c7####
 
(,L))  *)  
(-N++  ,+  
(,233% % 43 % 
(,G$$  %$ $ 	 	 	 L)). . *). 	 	 	 
(+J'', , (' , 
(+L))  *)  	 	 	 
(+& & &
 
(+   	 	 	 
(+& & &
 
(+   x|UY	22- - 32- EIuy!!  "!  r)   