The output of the function is the priority queue whose elements are the disjoint union of the elements of Q and R. Note that Q is altered in the process to become the merged queue.
i1 : Q = priorityQueue {2,4,6} o1 = PriorityQueue{...4...} o1 : PriorityQueue |
i2 : R = priorityQueue {1,3,5} o2 = PriorityQueue{...4...} o2 : PriorityQueue |
i3 : mergePQ(Q,R) o3 = PriorityQueue{...4...} o3 : PriorityQueue |
i4 : pop Q o4 = 1 |
i5 : pop Q o5 = 2 |
The priority queue Q is mutable and is altered by mergePQ. The elements of Q and R must be comparable to each other.
The object mergePQ is a method function.