Heap Implementation

Cem Karan cfkaran2 at gmail.com
Mon Feb 8 06:47:57 EST 2016


On Feb 7, 2016, at 10:15 PM, srinivas devaki <mr.eightnoteight at gmail.com> wrote:
> On Feb 8, 2016 7:07 AM, "Cem Karan" <cfkaran2 at gmail.com> wrote:
> > I know that there are methods of handling this from the client-side (tuples with unique counters come to mind), but if your library can handle it directly, then that could be useful to others as well.
> 
> yeah it is a good idea to do at client side.
> but if it should be introduced as feature into the library, instead of tuples, we should just piggyback a single counter it to the self._indexes dict, or better make another self._counts dict which will be light and fast.
> and if you think again with this method you can easily subclass with just using self._counts dict  in your subclass. but still I think it is good to introduce it as a feature in the library.
> 
> Regards
> Srinivas Devaki

Just to be 100% sure, you do mean to use the counters as UUIDs, right?  I don't mean that the elements in the heap get counted, I meant that the counter is a trick to separate different instances of (item, priority) pairs when you're pushing in the same item multiple times, but with different priorities.

Thanks,
Cem Karan


More information about the Python-list mailing list