Tim Peters added the comment:

@Rajath, I suspect Raymond may have been bamboozled because your suggested 
`heapfix()` and `heapremove()` didn't appear to take any arguments.  If the 
index is a required argument, then these are O(log N) operations.

I thought about adding them years ago, but didn't find a _plausible_ use case:  
the index at which a specific heap item appears is pretty much senseless, and 
typically varies over a heap's lifetime.  So how does the user know _which_ 
index to pass?  A linear search over the underlying list to find the index of a 
specific heap item is probably unacceptable.

The only hacks around that I could think of required a more complex kind of 
heap; e.g., restricting heap items to objects usable as dict keys, using a 
hidden dict to map heap items to their current index, and fiddling all the heap 
operations to keep that dict up to date.

So, in the absence of an obvious way to proceed, I gave up :-)

----------
nosy: +tim.peters

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31186>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to