Beispiel #1
0
 def _remove(item, selfref=ref(self)):
     self = selfref()
     if self is not None:
         if self._iterating:
             self._pending_removals.append(item)
         else:
             self.data.discard(item)
Beispiel #2
0
 def _remove(item, selfref=ref(self)):
     self = selfref()
     if self is not None:
         if self._iterating:
             self._pending_removals.append(item)
         else:
             self.data.discard(item)
Beispiel #3
0
 def __isub__(self, other):
     if self._pending_removals:
         self._commit_removals()
     if self is other:
         self.data.clear()
     else:
         self.data.difference_update(ref(item) for item in other)
     return self
Beispiel #4
0
 def __isub__(self, other):
     if self._pending_removals:
         self._commit_removals()
     if self is other:
         self.data.clear()
     else:
         self.data.difference_update(ref(item) for item in other)
     return self
Beispiel #5
0
 def __ixor__(self, other):
     if self._pending_removals:
         self._commit_removals()
     if self is other:
         self.data.clear()
     else:
         self.data.symmetric_difference_update(ref(item, self._remove) for item in other)
     return self
Beispiel #6
0
 def __ixor__(self, other):
     if self._pending_removals:
         self._commit_removals()
     if self is other:
         self.data.clear()
     else:
         self.data.symmetric_difference_update(
             ref(item, self._remove) for item in other)
     return self
Beispiel #7
0
 def issuperset(self, other):
     return self.data.issuperset(ref(item) for item in other)
Beispiel #8
0
 def __iand__(self, other):
     if self._pending_removals:
         self._commit_removals()
     self.data.intersection_update(ref(item) for item in other)
     return self
Beispiel #9
0
 def __init__(self, weakcontainer):
     # Don't create cycles
     self.weakcontainer = ref(weakcontainer)
Beispiel #10
0
 def discard(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.discard(ref(item))
Beispiel #11
0
 def discard(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.discard(ref(item))
Beispiel #12
0
 def __contains__(self, item):
     try:
         wr = ref(item)
     except TypeError:
         return False
     return wr in self.data
Beispiel #13
0
 def __gt__(self, other):
     return self.data > set(ref(item) for item in other)
Beispiel #14
0
 def __eq__(self, other):
     if not isinstance(other, self.__class__):
         return NotImplemented
     return self.data == set(ref(item) for item in other)
Beispiel #15
0
 def __gt__(self, other):
     return self.data > set(ref(item) for item in other)
Beispiel #16
0
 def issuperset(self, other):
     return self.data.issuperset(ref(item) for item in other)
Beispiel #17
0
 def __iand__(self, other):
     if self._pending_removals:
         self._commit_removals()
     self.data.intersection_update(ref(item) for item in other)
     return self
Beispiel #18
0
 def __init__(self, weakcontainer):
     # Don't create cycles
     self.weakcontainer = ref(weakcontainer)
Beispiel #19
0
 def __eq__(self, other):
     if not isinstance(other, self.__class__):
         return NotImplemented
     return self.data == set(ref(item) for item in other)
Beispiel #20
0
 def __contains__(self, item):
     try:
         wr = ref(item)
     except TypeError:
         return False
     return wr in self.data
Beispiel #21
0
 def add(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.add(ref(item, self._remove))
Beispiel #22
0
 def remove(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.remove(ref(item))
Beispiel #23
0
 def add(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.add(ref(item, self._remove))
Beispiel #24
0
 def remove(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.remove(ref(item))