okeuday / pqueue Goto Github PK
View Code? Open in Web Editor NEWErlang Priority Queues
License: MIT License
Erlang Priority Queues
License: MIT License
Even though pqueue does not impose proper dependency, it will fail compiling pqueue_proper module. I'd rather not include proper into another library I'd like to use pqueue from... Is there any way to make pqueue_proper compilation conditional somehow?
If I use PropEr to generate random sequences, the following one:
[{set,{var,1},{call,queue_srv,in,[-18]}},{set,{var,5},{call,queue_srv,in,[9]}},{set,{var,6},{call,queue_srv,in,[-10,-4]}},{set,{var,18},{call,queue_srv,in,[-29]}},{set,{var,22},{call,queue_srv,in,[11]}},{set,{var,26},{call,queue_srv,len,[]}}]
Fails. We basically "in" a lot of things... -18, 9, (-10 at prio -4), -29 and so on, followed by a call to len. This is the minimal test case, shrunk 12 times. The internal error is:
=ERROR REPORT==== 11-Nov-2011::16:27:08 ===
** Generic server queue_srv terminating
** Last message in was len
** When Server state == {state,pqueue2,
{-4,
{0,empty,empty,queue,{"\v",[-29]}},
{0,empty,empty,queue,{"\t",[-18]}},
element,-10}}
** Reason for termination ==
** {function_clause,[{pqueue2,merge,
[{0,empty,empty,queue,{"\v",[-29]}},
{0,empty,empty,queue,{"\t",[-18]}}],
[{file,"src/pqueue2.erl"},{line,444}]},
{pqueue2,out,1,[{file,"src/pqueue2.erl"},{line,173}]},
{pqueue2,len,1,[{file,"src/pqueue2.erl"},{line,144}]},
{queue_srv,handle_call,3,
[{file,"src/queue_srv.erl"},{line,98}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,578}]},
{proc_lib,init_p_do_apply,3,[]}]}
The following trace constructs an error, this time in pqueue
:
Shrinking .....(5 time(s))
[{set,{var,1},{call,queue_srv,in,[36,4]}},{set,{var,4},{call,queue_srv,out,[]}},{set,{var,6},{call,queue_srv,is_empty,[]}}]
History: [{{state,[]},ok},{{state,[{4,[36]}]},{value,36}},{{state,[]},false}]
State: {state,[]}
Result: {postcondition,false}
That is:
36
with priority 4
.pqueue:is_empty
on the resulting queue.This returns false
- the queue is not empty. But if we try to out
an element of the empty queue, we get told it is empty. There seem to be some problems with priorities.
There is a problem with either my model or pqueue2:
Shrinking .......(7 time(s))
[{set,{var,1},{call,queue_srv,in,[-11]}},{set,{var,3},{call,queue_srv,in,[12,-13]}},{set,{var,5},{call,queue_srv,in,[-21]}},{set,{var,8},{call,queue_srv,in,[6]}},{set,{var,12},{call,queue_srv,to_list,[]}}]
History: [{{state,[]},ok},{{state,[{0,[-11]}]},ok},{{state,[{-13,[12]},{0,[-11]}]},ok},{{state,[{-13,[12]},{0,[-11,-21]}]},ok},{{state,[{-13,[12]},{0,[-11,-21,6]}]},[12,-21,6,-11]}]
State: {state,[{-13,[12]},{0,[-11,-21,6]}]}
Result: {postcondition,false}
false
The error manifests itself in the call to_list/1
where the order is different from what is expected. We have 12
at priority -13
and then -11, -21, 6
at priority 0
. We expect the output to be [12, -11, -21, 6]
but it is [12, -21, 6, -11]
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.