Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 7
0
 def issuperset(self, other):
     return self.data.issuperset(ref(item) for item in other)
Esempio n. 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
Esempio n. 9
0
 def __init__(self, weakcontainer):
     # Don't create cycles
     self.weakcontainer = ref(weakcontainer)
Esempio n. 10
0
 def discard(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.discard(ref(item))
Esempio n. 11
0
 def discard(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.discard(ref(item))
Esempio n. 12
0
 def __contains__(self, item):
     try:
         wr = ref(item)
     except TypeError:
         return False
     return wr in self.data
Esempio n. 13
0
 def __gt__(self, other):
     return self.data > set(ref(item) for item in other)
Esempio n. 14
0
 def __eq__(self, other):
     if not isinstance(other, self.__class__):
         return NotImplemented
     return self.data == set(ref(item) for item in other)
Esempio n. 15
0
 def __gt__(self, other):
     return self.data > set(ref(item) for item in other)
Esempio n. 16
0
 def issuperset(self, other):
     return self.data.issuperset(ref(item) for item in other)
Esempio n. 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
Esempio n. 18
0
 def __init__(self, weakcontainer):
     # Don't create cycles
     self.weakcontainer = ref(weakcontainer)
Esempio n. 19
0
 def __eq__(self, other):
     if not isinstance(other, self.__class__):
         return NotImplemented
     return self.data == set(ref(item) for item in other)
Esempio n. 20
0
 def __contains__(self, item):
     try:
         wr = ref(item)
     except TypeError:
         return False
     return wr in self.data
Esempio n. 21
0
 def add(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.add(ref(item, self._remove))
Esempio n. 22
0
 def remove(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.remove(ref(item))
Esempio n. 23
0
 def add(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.add(ref(item, self._remove))
Esempio n. 24
0
 def remove(self, item):
     if self._pending_removals:
         self._commit_removals()
     self.data.remove(ref(item))