Efficient way to implement Priority Queue in Javascript?
问题 Priority Queues have a priority value and data, for every entry. Thus, when adding a new element to the queue, it bubbles up to the surface if it has a higher priority value than elements already in the collection. When one calls pop, we get the data for the element with highest priority. What is an efficient implementation of such a priority queue in Javascript? Does it make sense to have a new object called PriorityQueue, create two methods (push and pop) that take two params (data,