A priority queue is a data structure for storing a collection of totally ordered objects and keeping track of the minimum. This binomial heap implementation allows for efficiently adding a new element to the queue, accessing or deleting the minimum element, or merging two queues. Efficiently means time logarithmic in the size of the queue, or better.
i1 : Q = priorityQueue {3,7,1,5} o1 = PriorityQueue{...4...} o1 : PriorityQueue |
i2 : min Q o2 = 1 |
i3 : deleteMin Q; |
i4 : insert(Q,2); |
i5 : min Q o5 = 2 |
i6 : R = priorityQueue {4,6,8}; |
i7 : QR = mergePQ(Q,R); |
i8 : length QR o8 = 7 |
The object PriorityQueue is a type, with ancestor classes MutableHashTable < HashTable < Thing.