[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Rosetta Code Priority Queue
- From: Nagaev Boris <bnagaev@...>
- Date: Tue, 12 Apr 2016 12:12:31 +0000
On Tue, Apr 12, 2016 at 11:12 AM, Martin Krpan <wtxnh-lua@yahoo.com.au> wrote:
> 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
>
See https://github.com/Tieske/binaryheap.lua
--
Best regards,
Boris Nagaev