Talk:Priority queue: Difference between revisions

 
(7 intermediate revisions by 4 users not shown)
Line 1:
== Lua version broken? ==
 
I think the Lua version is broken. Well the default list of things works just fine and makes the correct output, if you change the list of priorities to:
<lang lua>tasks = {
{3, 'Clear drains'},
{334455, 'Feed cat'},
{441234, 'Make tea'},
{23, 'Solve RC tasks'},
{2, 'Tax return'}
}</lang>
You get what i think is completely, wrong output.
<lang>Putting: 3 - Clear drains
Putting: 334455 - Feed cat
Putting: 441234 - Make tea
Putting: 23 - Solve RC tasks
Putting: 2 - Tax return
Popped: 441234 - Make tea
Popped: 2 - Tax return
Popped: 334455 - Feed cat
Popped: 23 - Solve RC tasks
Popped: 3 - Clear drains</lang>
I think this happens because Lua guarantees no order to associative tables (key value pairs), the example is just lucky enough that that hashes are lining up or something.
 
== Refinement ==
 
Line 32 ⟶ 55:
The output of the C program seems wrong. I was expecting one copy of each item sorted in priority order? --[[User:Paddy3118|Paddy3118]] 05:31, 5 August 2011 (UTC)
: I have two queues, each with randomly selected 8 items and then merged, so output is a random combination of 16 items. --[[User:Ledrug|Ledrug]] 05:45, 5 August 2011 (UTC)
::Thanks for the explanation Ledrug. --[[User:Paddy3118|Paddy3118]] 06:01, 5 August 2011 (UTC)
 
Is it possible to agree on a suitable example for all language implementations to follow - to aid in comparisons - and then allow implementors to do extra if they want? It could be yours; it could be something else, but one common thing to do? --[[User:Paddy3118|Paddy3118]] 06:01, 5 August 2011 (UTC)
: Ok I'll edit the C code to use 5 items later. --[[User:Ledrug|Ledrug]] 06:17, 5 August 2011 (UTC)
:: Ta! --[[User:Paddy3118|Paddy3118]] 08:00, 5 August 2011 (UTC)
: Be very, very careful about embedding too many paradigm assumptions when looking for One Prescribed Way. And, yeah, different paradigms will tend to make comparison difficult, but those are the breaks. --[[User:Short Circuit|Michael Mol]] 12:31, 5 August 2011 (UTC)
 
==Ready to promote?==
I think it's good enough to go out of draft. --[[User:Ledrug|Ledrug]] 03:23, 29 August 2011 (UTC)
: Aye. --[[User:Paddy3118|Paddy3118]] 07:29, 29 August 2011 (UTC)
 
==Python Entries==
I think there's too much Python docs shown in the Python entries.