mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some change
This commit is contained in:
parent
636944632d
commit
60aa4fe93d
File diff suppressed because one or more lines are too long
@ -30,11 +30,10 @@ class set:
|
|||||||
return set(self._a.keys())
|
return set(self._a.keys())
|
||||||
|
|
||||||
def __and__(self, other):
|
def __and__(self, other):
|
||||||
ret = set()
|
return {elem for elem in self if elem in other}
|
||||||
for elem in self:
|
|
||||||
if elem in other:
|
def __sub__(self, other):
|
||||||
ret.add(elem)
|
return {elem for elem in self if elem not in other}
|
||||||
return ret
|
|
||||||
|
|
||||||
def __or__(self, other):
|
def __or__(self, other):
|
||||||
ret = self.copy()
|
ret = self.copy()
|
||||||
@ -42,13 +41,6 @@ class set:
|
|||||||
ret.add(elem)
|
ret.add(elem)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def __sub__(self, other):
|
|
||||||
ret = set()
|
|
||||||
for elem in self:
|
|
||||||
if elem not in other:
|
|
||||||
ret.add(elem)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def __xor__(self, other):
|
def __xor__(self, other):
|
||||||
ret = set()
|
ret = set()
|
||||||
for elem in self:
|
for elem in self:
|
||||||
@ -72,16 +64,18 @@ class set:
|
|||||||
return self ^ other
|
return self ^ other
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self.__xor__(other).__len__() == 0
|
if not isinstance(other, set):
|
||||||
|
return NotImplemented
|
||||||
|
return len(self ^ other) == 0
|
||||||
|
|
||||||
def isdisjoint(self, other):
|
def isdisjoint(self, other):
|
||||||
return self.__and__(other).__len__() == 0
|
return len(self & other) == 0
|
||||||
|
|
||||||
def issubset(self, other):
|
def issubset(self, other):
|
||||||
return self.__sub__(other).__len__() == 0
|
return len(self - other) == 0
|
||||||
|
|
||||||
def issuperset(self, other):
|
def issuperset(self, other):
|
||||||
return other.__sub__(self).__len__() == 0
|
return len(other - self) == 0
|
||||||
|
|
||||||
def __contains__(self, elem):
|
def __contains__(self, elem):
|
||||||
return elem in self._a
|
return elem in self._a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user