I hope it's of some use. Gé
Attachment:
pq.lua
Description: Binary data
On Mar 27, 2008, at 2:50 PM, Geoff Leyland wrote:
On 28/03/2008, at 12:36 AM, Tony Finch wrote:Good idea, but I tried it and it didn't seem to make a significant difference with lua or luajit. I also tried changing the entries to { k, v } rather than { key=k, value=v } figuring I'd swap some hash lookups for index lookups, but it was slightly slower on lua and only a little faster with luajit, so I figured it wasn't worth it. Javier's #self improvement is even better with luajit. I tried going further by having a manually updated self.size to avoid *all* the #selfs, but it was no better.On 2008年3月26日, Javier Guerra wrote: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 eachYou could avoid this by storing all the keys and values in one table anditem... no fair!the ordering in another, i.e. pairs[key] = value index[n] = keyCheers, Geoff
-- Gé Weijers ge@weijers.org