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