Double-Ended Heaps
Scott David Daniels
scott.daniels at acm.org
Mon Dec 19 02:49:22 EST 2005
Bryan Olson wrote:
> Note that any change to the contents of a DeHeap (and
> therefore a DeHeap2) any re-arrange the indices of a
> number of entries in the DeHeap.
Yup, thanks (I'll tweak it tomorrow).
> A useful Python class will follow Python convention, where
> relevant convention exists. In this case that means optionally
> passing the ordering relation; look at sort() and sorted().
That will be built from these. I have a little prototype,
but no tests yet.
> Adopting the convention will raises another issue: distinct
> objects can compare as equal, so the DeHeap2 operations that
> find items by value will be at least under-defined, and maybe
> even broken.
Actually, the issue already exists for elements which define
their own __lt__ function. The rule I will use is that you have
told the DeHeap to delete some member equal to the given value.
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list