oneShot: free the responder before running user func (avoid error)
[supercollider.git] / HelpSource / Classes / PriorityQueue.schelp
blob43a84e8789a642734634c2a9b8c7ece0b67dfd84
1 CLASS::PriorityQueue
2 summary:: Priority queue data structure
3 categories:: Collections>Ordered
5 DESCRIPTION::
6 PriorityQueue implements a priority queue data structure, which is used to build schedulers. It allows you to put in items at some arbitrary time and pop them in 
7 time order.
9 INSTANCEMETHODS::
11 method::put
12 Puts the item in the queue at the given time.
14 method::topPriority
15 Returns the time of the earliest item in the queue.
17 method::pop
18 Returns the earliest item in the queue.
20 method::clear
21 Empty the queue.
23 method::isEmpty
24 Return a link::Classes/Boolean:: whether the queue is empty.
26 method::notEmpty
27 Return a link::Classes/Boolean:: whether the queue is not empty.
29 EXAMPLES::
31 code::
33 var p;
34 p = PriorityQueue.new;
36 p.put(0.1, \a);
37 p.put(2.0, \b);
38 p.put(0.5, \c);
39 p.put(0.2, \d);
40 p.put(1.0, \e);
42 while ({ p.notEmpty },{
43         [p.topPriority, p.pop].postln;
44 });
47 p.pop.postln;
48 p.pop.postln;
49 p.pop.postln;
53 [ 0.1, a ]
54 [ 0.2, d ]
55 [ 0.5, c ]
56 [ 1, e ]
57 [ 2, b ]
58 nil
59 nil
60 nil