Safely move an element into a heap

Giampaolo Rodola' gnewsg at gmail.com
Thu Sep 4 13:28:28 CEST 2008


Hi,
I wanted to know if does exist a safe way to, given a heap, move an
arbitrary element to the first position of the heap.
Something like:

 >>> heap = [0,3,6,8,10]
 >>> heapq.move_to_first_position(heap, 4)
 >>> heap = [10, 0,3,6,8]


--- Giampaolo
http://code.google.com/p/pyftpdlib/



More information about the Python-list mailing list