Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
_weakrefset.WeakSet Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def __len__
def __contains__
def __reduce__
def add
def clear
def copy
def pop
def remove
def discard
def update
def __ior__
def difference
def difference_update
def __isub__
def intersection
def intersection_update
def __iand__
def issubset
def __le__
def issuperset
def __ge__
def __eq__
def symmetric_difference
def symmetric_difference_update
def __ixor__
def union
def isdisjoint

Public Attributes

 data

Private Member Functions

def _commit_removals
def _apply

Private Attributes

 _remove
 _pending_removals
 _iterating

Static Private Attributes

 __sub__ = difference
 __and__ = intersection
 __lt__ = issubset
 __gt__ = issuperset
 __xor__ = symmetric_difference
 __or__ = union

Detailed Description

Definition at line 35 of file _weakrefset.py.


Constructor & Destructor Documentation

def _weakrefset.WeakSet.__init__ (   self,
  data = None 
)

Definition at line 36 of file _weakrefset.py.

00036 
00037     def __init__(self, data=None):
00038         self.data = set()
00039         def _remove(item, selfref=ref(self)):
00040             self = selfref()
00041             if self is not None:
00042                 if self._iterating:
00043                     self._pending_removals.append(item)
00044                 else:
00045                     self.data.discard(item)
00046         self._remove = _remove
00047         # A list of keys to be removed
00048         self._pending_removals = []
00049         self._iterating = set()
00050         if data is not None:
00051             self.update(data)

Here is the caller graph for this function:


Member Function Documentation

def _weakrefset.WeakSet.__contains__ (   self,
  item 
)

Definition at line 68 of file _weakrefset.py.

00068 
00069     def __contains__(self, item):
00070         try:
00071             wr = ref(item)
00072         except TypeError:
00073             return False
00074         return wr in self.data

def _weakrefset.WeakSet.__eq__ (   self,
  other 
)

Definition at line 184 of file _weakrefset.py.

00184 
00185     def __eq__(self, other):
00186         if not isinstance(other, self.__class__):
00187             return NotImplemented
00188         return self.data == set(ref(item) for item in other)

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.__ge__ (   self,
  other 
)

Definition at line 181 of file _weakrefset.py.

00181 
00182     def __ge__(self, other):
00183         return self.data >= set(ref(item) for item in other)

Here is the call graph for this function:

def _weakrefset.WeakSet.__iand__ (   self,
  other 
)

Definition at line 164 of file _weakrefset.py.

00164 
00165     def __iand__(self, other):
00166         if self._pending_removals:
00167             self._commit_removals()
00168         self.data.intersection_update(ref(item) for item in other)
00169         return self

Here is the call graph for this function:

def _weakrefset.WeakSet.__ior__ (   self,
  other 
)

Definition at line 123 of file _weakrefset.py.

00123 
00124     def __ior__(self, other):
00125         self.update(other)
00126         return self

Here is the call graph for this function:

def _weakrefset.WeakSet.__isub__ (   self,
  other 
)

Definition at line 147 of file _weakrefset.py.

00147 
00148     def __isub__(self, other):
00149         if self._pending_removals:
00150             self._commit_removals()
00151         if self is other:
00152             self.data.clear()
00153         else:
00154             self.data.difference_update(ref(item) for item in other)
00155         return self

Here is the call graph for this function:

Definition at line 58 of file _weakrefset.py.

00058 
00059     def __iter__(self):
00060         with _IterationGuard(self):
00061             for itemref in self.data:
00062                 item = itemref()
00063                 if item is not None:
00064                     yield item

def _weakrefset.WeakSet.__ixor__ (   self,
  other 
)

Definition at line 200 of file _weakrefset.py.

00200 
00201     def __ixor__(self, other):
00202         if self._pending_removals:
00203             self._commit_removals()
00204         if self is other:
00205             self.data.clear()
00206         else:
00207             self.data.symmetric_difference_update(ref(item) for item in other)
00208         return self

Here is the call graph for this function:

def _weakrefset.WeakSet.__le__ (   self,
  other 
)

Definition at line 174 of file _weakrefset.py.

00174 
00175     def __le__(self, other):
00176         return self.data <= set(ref(item) for item in other)

Here is the call graph for this function:

Definition at line 65 of file _weakrefset.py.

00065 
00066     def __len__(self):
00067         return sum(x() is not None for x in self.data)

Here is the call graph for this function:

Definition at line 75 of file _weakrefset.py.

00075 
00076     def __reduce__(self):
00077         return (self.__class__, (list(self),),
00078                 getattr(self, '__dict__', None))

Here is the call graph for this function:

def _weakrefset.WeakSet._apply (   self,
  other,
  method 
) [private]

Definition at line 128 of file _weakrefset.py.

00128 
00129     def _apply(self, other, method):
00130         if not isinstance(other, self.__class__):
00131             other = self.__class__(other)
00132         newdata = method(other.data)
00133         newset = self.__class__()
00134         newset.data = newdata
00135         return newset

Here is the caller graph for this function:

def _weakrefset.WeakSet._commit_removals (   self) [private]

Definition at line 52 of file _weakrefset.py.

00052 
00053     def _commit_removals(self):
00054         l = self._pending_removals
00055         discard = self.data.discard
00056         while l:
00057             discard(l.pop())

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.add (   self,
  item 
)

Definition at line 79 of file _weakrefset.py.

00079 
00080     def add(self, item):
00081         if self._pending_removals:
00082             self._commit_removals()
00083         self.data.add(ref(item, self._remove))

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.clear (   self)

Definition at line 84 of file _weakrefset.py.

00084 
00085     def clear(self):
00086         if self._pending_removals:
00087             self._commit_removals()
00088         self.data.clear()

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.copy (   self)

Definition at line 89 of file _weakrefset.py.

00089 
00090     def copy(self):
00091         return self.__class__(self)

def _weakrefset.WeakSet.difference (   self,
  other 
)

Definition at line 136 of file _weakrefset.py.

00136 
00137     def difference(self, other):
        return self._apply(other, self.data.difference)

Here is the call graph for this function:

def _weakrefset.WeakSet.difference_update (   self,
  other 
)

Definition at line 140 of file _weakrefset.py.

00140 
00141     def difference_update(self, other):
00142         if self._pending_removals:
00143             self._commit_removals()
00144         if self is other:
00145             self.data.clear()
00146         else:
            self.data.difference_update(ref(item) for item in other)

Here is the call graph for this function:

def _weakrefset.WeakSet.discard (   self,
  item 
)

Definition at line 109 of file _weakrefset.py.

00109 
00110     def discard(self, item):
00111         if self._pending_removals:
00112             self._commit_removals()
00113         self.data.discard(ref(item))

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.intersection (   self,
  other 
)

Definition at line 156 of file _weakrefset.py.

00156 
00157     def intersection(self, other):
        return self._apply(other, self.data.intersection)

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.intersection_update (   self,
  other 
)

Definition at line 160 of file _weakrefset.py.

00160 
00161     def intersection_update(self, other):
00162         if self._pending_removals:
00163             self._commit_removals()
        self.data.intersection_update(ref(item) for item in other)

Here is the call graph for this function:

def _weakrefset.WeakSet.isdisjoint (   self,
  other 
)

Definition at line 213 of file _weakrefset.py.

00213 
00214     def isdisjoint(self, other):
00215         return len(self.intersection(other)) == 0

Here is the call graph for this function:

def _weakrefset.WeakSet.issubset (   self,
  other 
)

Definition at line 170 of file _weakrefset.py.

00170 
00171     def issubset(self, other):
        return self.data.issubset(ref(item) for item in other)
def _weakrefset.WeakSet.issuperset (   self,
  other 
)

Definition at line 177 of file _weakrefset.py.

00177 
00178     def issuperset(self, other):
        return self.data.issuperset(ref(item) for item in other)
def _weakrefset.WeakSet.pop (   self)

Definition at line 92 of file _weakrefset.py.

00092 
00093     def pop(self):
00094         if self._pending_removals:
00095             self._commit_removals()
00096         while True:
00097             try:
00098                 itemref = self.data.pop()
00099             except KeyError:
00100                 raise KeyError('pop from empty WeakSet')
00101             item = itemref()
00102             if item is not None:
00103                 return item

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.remove (   self,
  item 
)

Definition at line 104 of file _weakrefset.py.

00104 
00105     def remove(self, item):
00106         if self._pending_removals:
00107             self._commit_removals()
00108         self.data.remove(ref(item))

Here is the call graph for this function:

Here is the caller graph for this function:

def _weakrefset.WeakSet.symmetric_difference (   self,
  other 
)

Definition at line 189 of file _weakrefset.py.

00189 
00190     def symmetric_difference(self, other):
        return self._apply(other, self.data.symmetric_difference)

Here is the call graph for this function:

Definition at line 193 of file _weakrefset.py.

00193 
00194     def symmetric_difference_update(self, other):
00195         if self._pending_removals:
00196             self._commit_removals()
00197         if self is other:
00198             self.data.clear()
00199         else:
            self.data.symmetric_difference_update(ref(item) for item in other)

Here is the call graph for this function:

def _weakrefset.WeakSet.union (   self,
  other 
)

Definition at line 209 of file _weakrefset.py.

00209 
00210     def union(self, other):
        return self._apply(other, self.data.union)

Here is the call graph for this function:

def _weakrefset.WeakSet.update (   self,
  other 
)

Definition at line 114 of file _weakrefset.py.

00114 
00115     def update(self, other):
00116         if self._pending_removals:
00117             self._commit_removals()
00118         if isinstance(other, self.__class__):
00119             self.data.update(other.data)
00120         else:
00121             for element in other:
00122                 self.add(element)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 158 of file _weakrefset.py.

Definition at line 179 of file _weakrefset.py.

_weakrefset.WeakSet.__lt__ = issubset [static, private]

Definition at line 172 of file _weakrefset.py.

_weakrefset.WeakSet.__or__ = union [static, private]

Definition at line 211 of file _weakrefset.py.

Definition at line 138 of file _weakrefset.py.

Definition at line 191 of file _weakrefset.py.

Definition at line 48 of file _weakrefset.py.

Definition at line 47 of file _weakrefset.py.

Definition at line 45 of file _weakrefset.py.

Definition at line 37 of file _weakrefset.py.


The documentation for this class was generated from the following file: