|
|
||
|
On Wed, Mar 26, 2008 at 1:43 PM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:Here's the code with the tests. No guarantees it works :)
a simpleminded optimization (reduce the use of #self) gains a 20% speedup:
ok, i wrote the 'h:reheapify()' function:
but also noted that your speed test of the sort()ed queue just inserts numbers in the queue, while the heap uses a {key,value} table for each item... no fair!
with the overhead of creating a table per item, and using a Lua callback for sorting... it's far,far worse than a heap, both lazy and eager!
Cheers, Geoff