Home | Trees | Indices | Help |
|
---|
|
object --+ | list --+ | UnorderedList
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.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
|||
Inherited from |
|
Definition of
|
Definition of
|
Definition of ≥ operator for this class.
|
Definition of
|
Definition of ≤ operator for this class.
|
Definition of
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jul 26 00:57:52 2015 | http://epydoc.sourceforge.net |