1 var define = require("../define").define, 2 MinHeap = require("./MinHeap"), 3 base = require("../base"); 4 var PriorityQueue; 5 6 /** 7 * @class PriorityQueue Implementation where the value with the highest priority moves to the front 8 * Priority starts at 0, and the greatest value being the lowest priority; 9 * @augments comb.collections.MinHeap 10 * @memberOf comb.collections 11 */ 12 PriorityQueue = define(MinHeap, { 13 instance : { 14 /**@lends comb.collections.PriorityQueue.prototype*/ 15 16 /** 17 * Adds the value with the specified priority to the queue 18 * 19 * @param {Number} priority the priority of the item 20 * </br> 21 * <b>0 = Highest, n = lowest</b> 22 * @param value 23 */ 24 enqueue : function(priority, value) { 25 return this.insert(priority, value); 26 }, 27 28 /** 29 * Removes the item with the highest priority from the queue 30 * 31 * @returns the value of the item 32 */ 33 dequeue : function() { 34 return this.remove(); 35 } 36 } 37 }); 38 39 module.exports = exports = PriorityQueue;