ACC SHELL

Path : /usr/lib/python/
File Upload :
Current File : //usr/lib/python/sets.pyc

Ñò
oÄMc@s'dZddklZyddklZlZWngej
o[d„Zd„ZyeefWn1e	j
o%ddjddjf\ZZnXnXddd	gZ
dd
kZeide
dd
ƒdefd„ƒYZd	efd„ƒYZdefd„ƒYZdefd„ƒYZd
S(såClasses to represent arbitrary sets (including sets of sets).

This module implements sets using dictionaries whose values are
ignored.  The usual operations (union, intersection, deletion, etc.)
are provided as both methods and operators.

Important: sets are not sequences!  While they support 'x in s',
'len(s)', and 'for x in s', none of those operations are unique for
sequences; for example, mappings support all three as well.  The
characteristic operation for sequences is subscripting with small
integers: s[i], for i in range(len(s)).  Sets don't support
subscripting at all.  Also, sequences allow multiple occurrences and
their elements have a definite order; sets on the other hand don't
record multiple occurrences and don't remember the order of element
insertion (which is why they don't support s[i]).

The following classes are provided:

BaseSet -- All the operations common to both mutable and immutable
    sets. This is an abstract class, not meant to be directly
    instantiated.

Set -- Mutable sets, subclass of BaseSet; not hashable.

ImmutableSet -- Immutable sets, subclass of BaseSet; hashable.
    An iterable argument is mandatory to create an ImmutableSet.

_TemporarilyImmutableSet -- A wrapper around a Set, hashable,
    giving the same hash value as the immutable set equivalent
    would have.  Do not use this class directly.

Only hashable objects can be added to a Set. In particular, you cannot
really add a Set as an element to another Set; if you try, what is
actually added is an ImmutableSet built from it (it compares equal to
the one you tried adding).

When you ask if `x in y' where x is a Set and y is a Set or
ImmutableSet, x is wrapped into a _TemporarilyImmutableSet z, and
what's tested is actually `z in y'.

iÿÿÿÿ(t
generators(tifiltertifilterfalseccsE|djo
d„}nx$|D]}||ƒo	|Vq!q!WdS(NcSs|S(N((tx((s/usr/lib/python2.6/sets.pyt	predicate@s(tNone(RtiterableR((s/usr/lib/python2.6/sets.pyR>s


ccsE|djo
d„}nx$|D]}||ƒp	|Vq!q!WdS(NcSs|S(N((R((s/usr/lib/python2.6/sets.pyRGs(R(RRR((s/usr/lib/python2.6/sets.pyREs


itBaseSettSettImmutableSetNsthe sets module is deprecatedt
stacklevelicBseZdZdgZd„Zd„Zd„ZeZed„Z	d„Z
d„Zd„Zd	„Z
d
„ZeZd„Zd„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZeZeZd„Zd„Zd„Z d„Z!d„Z"RS(s1Common base class for mutable and immutable sets.t_datacCs!|itjo
td‚ndS(sThis is an abstract class.s7BaseSet is an abstract class.  Use Set or ImmutableSet.N(t	__class__Rt	TypeError(tself((s/usr/lib/python2.6/sets.pyt__init__^scCs
t|iƒS(s'Return the number of elements of a set.(tlenR(R((s/usr/lib/python2.6/sets.pyt__len__gscCs
|iƒS(seReturn string representation of a set.

        This looks like 'Set([<list of elements>])'.
        (t_repr(R((s/usr/lib/python2.6/sets.pyt__repr__kscCs8|iiƒ}|o|iƒnd|ii|fS(Ns%s(%r)(RtkeystsortRt__name__(Rtsortedtelements((s/usr/lib/python2.6/sets.pyRuscCs
|iiƒS(ssReturn an iterator over the elements or a set.

        This is the keys iterator for the underlying dict.
        (Rtiterkeys(R((s/usr/lib/python2.6/sets.pyt__iter__{scCs
td‚dS(Nscan't compare sets using cmp()(R
(Rtother((s/usr/lib/python2.6/sets.pyt__cmp__‡scCs)t|tƒo|i|ijStSdS(N(t
isinstanceRRtFalse(RR((s/usr/lib/python2.6/sets.pyt__eq__™scCs)t|tƒo|i|ijStSdS(N(RRRtTrue(RR((s/usr/lib/python2.6/sets.pyt__ne__ŸscCs#|iƒ}|ii|iƒ|S(sReturn a shallow copy of a set.(RRtupdate(Rtresult((s/usr/lib/python2.6/sets.pytcopy§scCscddkl}|iƒ}||t|ƒ<|i}t}x!|D]}|||||ƒ<qBW|S(s1Return a deep copy of a set; used by copy module.iÿÿÿÿ(tdeepcopy(R$R%RtidRR (RtmemoR%R#tdatatvaluetelt((s/usr/lib/python2.6/sets.pyt__deepcopy__¯s	cCs"t|tƒptS|i|ƒS(shReturn the union of two sets as a new set.

        (I.e. all elements that are in either set.)
        (RRtNotImplementedtunion(RR((s/usr/lib/python2.6/sets.pyt__or__ÈscCs |i|ƒ}|i|ƒ|S(shReturn the union of two sets as a new set.

        (I.e. all elements that are in either set.)
        (Rt_update(RRR#((s/usr/lib/python2.6/sets.pyR-Ñs
cCs"t|tƒptS|i|ƒS(snReturn the intersection of two sets as a new set.

        (I.e. all elements that are in both sets.)
        (RRR,tintersection(RR((s/usr/lib/python2.6/sets.pyt__and__ÚscCsyt|tƒpt|ƒ}nt|ƒt|ƒjo||}}n||}}t|ii|ƒ}|i|ƒS(snReturn the intersection of two sets as a new set.

        (I.e. all elements that are in both sets.)
        (RRRRRRthas_keyR(RRtlittletbigtcommon((s/usr/lib/python2.6/sets.pyR0ãs
cCs"t|tƒptS|i|ƒS(s„Return the symmetric difference of two sets as a new set.

        (I.e. all elements that are in exactly one of the sets.)
        (RRR,tsymmetric_difference(RR((s/usr/lib/python2.6/sets.pyt__xor__ñsc	Cs¨|iƒ}|i}t}|i}y
|i}Wn"tj
ot|ƒi}nXx$t|i|ƒD]}|||<qiWx$t|i|ƒD]}|||<qW|S(s„Return the symmetric difference of two sets as a new set.

        (I.e. all elements that are in exactly one of the sets.)
        (RRR tAttributeErrorRRR2(RRR#R(R)tselfdatat	otherdataR*((s/usr/lib/python2.6/sets.pyR6ús		
cCs"t|tƒptS|i|ƒS(s€Return the difference of two sets as a new Set.

        (I.e. all elements that are in this set and not in the other.)
        (RRR,t
difference(RR((s/usr/lib/python2.6/sets.pyt__sub__
scCsx|iƒ}|i}y
|i}Wn"tj
ot|ƒi}nXt}x$t|i|ƒD]}|||<q`W|S(s€Return the difference of two sets as a new Set.

        (I.e. all elements that are in this set and not in the other.)
        (RRR8RR RR2(RRR#R(R:R)R*((s/usr/lib/python2.6/sets.pyR;s	
cCs^y||ijSWnFtj
o:t|ddƒ}|djo‚n|ƒ|ijSXdS(s{Report whether an element is a member of a set.

        (Called in response to the expression `element in self'.)
        t__as_temporarily_immutable__N(RR
tgetattrR(Rtelementt	transform((s/usr/lib/python2.6/sets.pyt__contains__(s
cCsP|i|ƒt|ƒt|ƒjotSxt|ii|ƒD]}tSWtS(s-Report whether another set contains this set.(t_binary_sanity_checkRRRRR2R (RRR*((s/usr/lib/python2.6/sets.pytissubset7s
cCsP|i|ƒt|ƒt|ƒjotSxt|ii|ƒD]}tSWtS(s-Report whether this set contains another set.(RBRRRRR2R (RRR*((s/usr/lib/python2.6/sets.pyt
issuperset@s
cCs3|i|ƒt|ƒt|ƒjo
|i|ƒS(N(RBRRC(RR((s/usr/lib/python2.6/sets.pyt__lt__Ms
cCs3|i|ƒt|ƒt|ƒjo
|i|ƒS(N(RBRRD(RR((s/usr/lib/python2.6/sets.pyt__gt__Qs
cCs!t|tƒp
td‚ndS(Ns,Binary operation only permitted between sets(RRR
(RR((s/usr/lib/python2.6/sets.pyRBWscCs+d}x|D]}|t|ƒN}q
W|S(Ni(thash(RR#R*((s/usr/lib/python2.6/sets.pyt
_compute_hash]s
cCsG|i}t|tƒo|i|iƒdSt}t|ƒtttfjo‹t	|ƒ}xätopy#x|D]}|||<qpWdSWq_t
j
o:t|ddƒ}|djo‚n|||ƒ<q_Xq_Wnixe|D]]}y|||<Wqât
j
o:t|ddƒ}|djo‚n|||ƒ<qâXqâWdS(Nt__as_immutable__(
RRRR"R ttypetlistttupletxrangetiterR
R>R(RRR(R)titR?R@((s/usr/lib/python2.6/sets.pyR/hs8	

(#Rt
__module__t__doc__t	__slots__RRRt__str__RRRRRR!R$t__copy__R+R.R-R1R0R7R6R<R;RARCRDt__le__t__ge__RERFRBRHR/(((s/usr/lib/python2.6/sets.pyRWs@																												
				cBs>eZdZdgZdd„Zd„Zd„Zd„ZRS(sImmutable set class.t	_hashcodecCs4d|_h|_|dj	o|i|ƒndS(s5Construct an immutable set from an optional iterable.N(RRWRR/(RR((s/usr/lib/python2.6/sets.pyR”s		
cCs*|idjo|iƒ|_n|iS(N(RWRRH(R((s/usr/lib/python2.6/sets.pyt__hash__›scCs|i|ifS(N(RRW(R((s/usr/lib/python2.6/sets.pyt__getstate__ scCs|\|_|_dS(N(RRW(Rtstate((s/usr/lib/python2.6/sets.pyt__setstate__£sN(	RRPRQRRRRRXRYR[(((s/usr/lib/python2.6/sets.pyR	s			cBsÈeZdZgZdd„Zd„Zd„ZdZd„Z	d„Z
d„Zd„Zd„Z
d	„Zd
„Zd„Zd„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s Mutable set class.cCs+h|_|dj	o|i|ƒndS(s*Construct a set from an optional iterable.N(RRR/(RR((s/usr/lib/python2.6/sets.pyR­s	
cCs
|ifS(N(R(R((s/usr/lib/python2.6/sets.pyRY³scCs|\|_dS(N(R(RR(((s/usr/lib/python2.6/sets.pyR[·scCs$|i|ƒ|ii|iƒ|S(s2Update a set with the union of itself and another.(RBRR"(RR((s/usr/lib/python2.6/sets.pyt__ior__Âs
cCs|i|ƒdS(s2Update a set with the union of itself and another.N(R/(RR((s/usr/lib/python2.6/sets.pytunion_updateÈscCs!|i|ƒ||@i|_|S(s9Update a set with the intersection of itself and another.(RBR(RR((s/usr/lib/python2.6/sets.pyt__iand__Ìs
cCs7t|tƒo||M}n|i|ƒi|_dS(s9Update a set with the intersection of itself and another.N(RRR0R(RR((s/usr/lib/python2.6/sets.pytintersection_updateÒscCs|i|ƒ|i|ƒ|S(sAUpdate a set with the symmetric difference of itself and another.(RBtsymmetric_difference_update(RR((s/usr/lib/python2.6/sets.pyt__ixor__Ùs

cCs|i}t}t|tƒpt|ƒ}n||jo|iƒnx0|D](}||jo||=qQ|||<qQWdS(sAUpdate a set with the symmetric difference of itself and another.N(RR RRRtclear(RRR(R)R*((s/usr/lib/python2.6/sets.pyR`ßs	

cCs|i|ƒ|i|ƒ|S(s1Remove all elements of another set from this set.(RBtdifference_update(RR((s/usr/lib/python2.6/sets.pyt__isub__ís

cCsl|i}t|tƒpt|ƒ}n||jo|iƒnx!t|i|ƒD]
}||=qWWdS(s1Remove all elements of another set from this set.N(RRRRRbRR2(RRR(R*((s/usr/lib/python2.6/sets.pyRcós	
cCs|i|ƒdS(s9Add all values from an iterable (such as a list or file).N(R/(RR((s/usr/lib/python2.6/sets.pyR"ÿscCs|iiƒdS(s"Remove all elements from this set.N(RRb(R((s/usr/lib/python2.6/sets.pyRbscCsayt|i|<WnItj
o=t|ddƒ}|djo‚nt|i|ƒ<nXdS(s`Add an element to a set.

        This has no effect if the element is already present.
        RIN(R RR
R>R(RR?R@((s/usr/lib/python2.6/sets.pytadd	s
cCs[y|i|=WnFtj
o:t|ddƒ}|djo‚n|i|ƒ=nXdS(svRemove an element from a set; it must be a member.

        If the element is not a member, raise a KeyError.
        R=N(RR
R>R(RR?R@((s/usr/lib/python2.6/sets.pytremoves
cCs+y|i|ƒWntj
onXdS(smRemove an element from a set if it is a member.

        If the element is not a member, do nothing.
        N(RftKeyError(RR?((s/usr/lib/python2.6/sets.pytdiscard#scCs|iiƒdS(s+Remove and return an arbitrary set element.i(Rtpopitem(R((s/usr/lib/python2.6/sets.pytpop-scCs
t|ƒS(N(R	(R((s/usr/lib/python2.6/sets.pyRI1scCs
t|ƒS(N(t_TemporarilyImmutableSet(R((s/usr/lib/python2.6/sets.pyR=5sN(RRPRQRRRRRYR[RXR\R]R^R_RaR`RdRcR"RbReRfRhRjRIR=(((s/usr/lib/python2.6/sets.pyR¦s,													
	
	
		RkcBseZd„Zd„ZRS(cCs||_|i|_dS(N(t_setR(Rtset((s/usr/lib/python2.6/sets.pyR>s	cCs
|iiƒS(N(RlRH(R((s/usr/lib/python2.6/sets.pyRXBs(RRPRRX(((s/usr/lib/python2.6/sets.pyRk:s	(RQt
__future__Rt	itertoolsRRtImportErrorR Rt	NameErrort__all__twarningstwarntDeprecationWarningtobjectRR	RRk(((s/usr/lib/python2.6/sets.pyt<module>)s&		(ÿ7”

ACC SHELL 2018