lua-users home
lua-l archive

Rosetta Code Priority Queue

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I was looking for priority queue and found this implementation on
Rosetta Code (Lua implementation):
https://rosettacode.org/wiki/Priority_queue#Lua
Or I am doing something really stupid or that Lua implementation is not
right. I mean it passes all assertion when i copy/paste and run the
code. But when i change the test code a little it breaks.
If I change n and m parameters in such way that m > n
assertion fails.
Also if I insert a line
math.randomseed(os.time())
in test then assersion fails too.
I think author is expecting that this line in pop function
 for p, q in pairs(self) do
will return elements sorted by p (and to make things interesting, in
some cases it does).
Anybody care to replace that code for good one?
Martin

AltStyle によって変換されたページ (->オリジナル) /