Javascript Google Closure Tools PriorityQueue错误顺序

Javascript Google Closure Tools PriorityQueue错误顺序,javascript,priority-queue,google-closure,google-closure-library,Javascript,Priority Queue,Google Closure,Google Closure Library,我已使用以下enqueue方法创建了一个唯一的优先级队列: huzz.ak.UniquePriorityQueue.prototype.enqueue = function(priority, value) { var node = {'valid': true, 'value': value, 'priority': priority}; var key = value.key; if (this.pointers_[key] !== undefined) { th

我已使用以下enqueue方法创建了一个唯一的优先级队列:

huzz.ak.UniquePriorityQueue.prototype.enqueue =
    function(priority, value) {
  var node = {'valid': true, 'value': value, 'priority': priority};
  var key = value.key;
  if (this.pointers_[key] !== undefined) {
    this.pointers_[key].valid = false;
  }
  this.pointers_[key] = node;
  this.priorityQueue_.enqueue(priority, node);
};
当我输出值时,它们以随机顺序出现:

while (true) {
  p = this.priorityQueue_.dequeue();
  this.logger_.log(p.priority + ' ' + p.value.toString() + ' ' + p.valid);
}

1265 ... true

1413 S..N. false

1265 ... false

92 S..N. true

1734 .........E false

59 ... false

75 ...B false

92 S..N. false
为什么队列没有按预期顺序(从最小到最大)返回值


谢谢

事实证明,在我的部分代码中,我传递的是一个列表,而不是列表的长度,这一切都搞砸了。我修复了此错误,优先级队列按预期工作