HWRF
trunk@4391
|
Sorts a pre-determined list of objects, placing unknown items at a specified location. More...
Sorts a pre-determined list of objects, placing unknown items at a specified location.
This class is a drop-in replacement for cmp in sorting routines. It represents a partial ordering of objects by specifying the order of a known subset of those objects, and inserting all unknown objects in a specified location in the that list (at the end, by default) in an order determined by cmp(a,b). Example:
Definition at line 21 of file numerics.py.
Public Member Functions | |
def | __init__ |
partial_ordering constructor. More... | |
def | __call__ (self, a, b) |
Determine the ordering of a and b. More... | |
Public Attributes | |
order | |
Internal ordering information. | |
backupcmp | |
Backup comparison function for tiebreaking. | |
unordered | |
Unordered element index. | |
def hwrf.numerics.partial_ordering.__init__ | ( | self, | |
ordering, | |||
unordered = None , |
|||
backupcmp = cmp |
|||
) |
partial_ordering constructor.
Creates a partial ordering. The subset that is ordered is specified by the ordered iterable "ordered" while the index at which to place unordered values is optionally specified by "unordered", which can be anything that can be cmp()'ed to an int. If "unordered" is missing, then all objects not in "ordered" will be placed at the end of any list. To place at the beginning of the list, give unordered=0. To insert between the first and second elements, specify 1, between second and third elements: specify unordered=2, and so on. Specify another tiebreaker "cmp" function with "backupcmp" (default: cmp).
ordering | the ordering of known objects |
unordered | Optional: where to put other objects |
backupcmp | Tiebreaker comparison function. |
Definition at line 42 of file numerics.py.
def hwrf.numerics.partial_ordering.__call__ | ( | self, | |
a, | |||
b | |||
) |
Determine the ordering of a and b.
a,b | the objects to order |
Definition at line 86 of file numerics.py.