|
|
||
|
On 27/03/2008, at 2:39 AM, Roberto Ierusalimschy wrote:does table.qsort exist? I can only find table.sort documented.
table.sort uses the quicksort algorithm, if that is what you mean.
Geoff Leyland wrote:Good question. I just tested (b) vs a pure lua binary heap and the binary heap is so much better (the sort version still hasn't finished) that I think I must have got (b) wrong (does table.qsort exist? I can only find table.sort documented. Which is better out of table_insert(t, x) and t[#t+1] = x?)
If you want to try my heap code I can send it, but I think there's one in loop that's bound to be better.
That deeply surprises me, but I can hardly argue with results --- so, yes please, I'd love a copy.
So I guess the answer is that it depends what you're doing.
Here's the code with the tests. No guarantees it works :)
Cheers, Geoff
Attachment:
binary_heap-test.lua
Description: Binary data
Attachment:
binary_heap.lua
Description: Binary data