deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / Common / Collections / PriorityQueue.sc
blob248e12076abe9ae395059dc93a9d19a77f66c2f4
1 PriorityQueue {
2         var array;
4         put { arg time, item;
5                 _PriorityQueueAdd
6                 ^this.primitiveFailed;
7         }
8         pop {
9                 _PriorityQueuePop
10                 ^this.primitiveFailed;
11         }
12         topPriority {
13                 _PriorityQueueTop
14                 ^this.primitiveFailed;
15         }
16         clear {
17                 _PriorityQueueClear
18                 ^this.primitiveFailed;
19         }
20         postpone { arg time;
21                 _PriorityQueuePostpone
22                 ^this.primitiveFailed;
23         }
24         isEmpty {
25                 _PriorityQueueEmpty
26                 ^this.primitiveFailed;
27         }
28         notEmpty { ^this.isEmpty.not }
30         removeValue {|value|
31                 var newObject = PriorityQueue(), currentPriority, topObject;
33                 while {this.notEmpty} {
34                         currentPriority = this.topPriority;
35                         topObject = this.pop;
36                         if (topObject != value) {
37                                 newObject.put(currentPriority, topObject)
38                         }
39                 };
40                 array = newObject.prInternalArray;
41         }
43         do {|func|
44                 if (array.size > 1) {
45                         forBy(1, array.size-1, 3) {|i|
46                                 func.value(array[i+1],array[i+0])
47                         }
48                 }
49         }
51         // private
52         prInternalArray {
53                 ^array
54         }