heapq.heappush and pop to use key

2007-03-08 Thread [EMAIL PROTECTED]
I wanted to have a heap of custom objects, and in different heaps I wanted to have the weights for my elements differently. So, I modified the heapq module to accept key arguments also. The untested code is here. Please let me know if you find any bug or if there is an easy way to do this. -

Re: heapq.heappush and pop to use key

2007-03-08 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I wanted to have a heap of custom objects, and in different heaps I wanted to have the weights for my elements differently. So, I modified the heapq module to accept key arguments also. I would have just used tuples of the form (weight, obj) with

Re: heapq.heappush and pop to use key

2007-03-08 Thread [EMAIL PROTECTED]
On Mar 8, 9:02 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I wanted to have a heap of custom objects, and in different heaps I wanted to have the weights for my elements differently. So, I modified the heapq module to accept key