-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepriq_test.erl
32 lines (25 loc) · 903 Bytes
/
epriq_test.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-module(epriq_test).
-author('[email protected]').
-export([run/0,
run/2]).
-include("epriq.hrl").
run() ->
run(100, 10).
run(Size, PriorityRange) ->
Seq = lists:seq(1, Size),
Queue = lists:foldl(fun(Value, Queue0) ->
Priority = rand:uniform(PriorityRange),
Node = #epriq_queue_node{priority = Priority,
value = Value},
epriq:add_node(Node, Queue0)
end,
epriq:init(),
Seq),
lists:foldl(fun(_, Queue0) ->
{ok, Node, Queue1} = epriq:get_node(Queue0),
io:format("===> Node: ~p~n", [Node]),
Queue1
end,
Queue,
Seq),
ok.