Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module util :: Class UnorderedList |
|
object
--+ |list
--+ | UnorderedList
AbsolutePathList
,
ObjectTypeList
,
RestrictedContentList
Class representing an "unordered list".
An "unordered list" is a list in which only the contents matter, not the order in which the contents appear in the list.
For instance, we might be keeping track of set of paths in a list, because it's convenient to have them in that form. However, for comparison purposes, we would only care that the lists contain exactly the same contents, regardless of order.
I have come up with two reasonable ways of doing this, plus a couple more that would work but would be a pain to implement. My first method is to copy and sort each list, comparing the sorted versions. This will only work if two lists with exactly the same members are guaranteed to sort in exactly the same order. The second way would be to create two Sets and then compare the sets. However, this would lose information about any duplicates in either list. I've decided to go with option #1 for now. I'll modify this code if I run into problems in the future.
We override the original__eq__
, __ne__
,
__ge__
, __gt__
, __le__
and
__lt__
list methods to change the definition of the various
comparison operators. In all cases, the comparison is changed to return
the result of the original operation but instead comparing sorted
lists. This is going to be quite a bit slower than a normal list, so
you probably only want to use it on small lists.
Method Summary | |
---|---|
Definition of == operator for this class. | |
Definition of ≥ operator for this class. | |
Definition of > operator for this class. | |
Definition of ≤ operator for this class. | |
Definition of < operator for this class. | |
Definition of != operator for this class. | |
Inherited from list | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__add__(y) <==> x+y | |
x.__contains__(y) <==> y in x | |
x.__delitem__(y) <==> del x[y] | |
Use of negative indices is not supported. | |
x.__getattribute__('name') <==> x.name | |
x.__getitem__(y) <==> x[y] | |
Use of negative indices is not supported. | |
x.__hash__() <==> hash(x) | |
x.__iadd__(y) <==> x+=y | |
x.__imul__(y) <==> x*=y | |
x.__iter__() <==> iter(x) | |
x.__len__() <==> len(x) | |
x.__mul__(n) <==> x*n | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
x.__repr__() <==> repr(x) | |
x.__rmul__(n) <==> n*x | |
x.__setitem__(i, y) <==> x[i]=y | |
Use of negative indices is not supported. | |
L.append(object) -- append object to end | |
L.count(value) -> integer -- return number of occurrences of value | |
L.extend(iterable) -- extend list by appending elements from the iterable | |
L.index(value, [start, [stop]]) -> integer -- return first index of value | |
L.insert(index, object) -- insert object before index | |
L.pop([index]) -> item -- remove and return item at index (default last) | |
L.remove(value) -- remove first occurrence of value | |
L.reverse() -- reverse *IN PLACE* | |
L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) -> -1, 0, 1 | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Method Details |
---|
__eq__(self,
other)
Definition of |
__ge__(self,
other)
Definition of ≥ operator for this class.
|
__gt__(self,
other)
Definition of |
__le__(self,
other)
Definition of ≤ operator for this class.
|
__lt__(self,
other)
Definition of |
__ne__(self, other)Definition of!= operator for this class.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Dec 22 20:45:14 2005 | http://epydoc.sf.net |