"use strict";

export class PriorityQueue {
  items = [];
  constructor(compareFunction) {
    this.compare = compareFunction;
  }
  push(item) {
    this.items.push(item);
    this.items.sort(this.compare);
  }

  //should take variable size, so it could pop more than 1 item
  pop(size = 1) {
    const poppedItems = this.items.splice(0, size);
    return poppedItems;
  }
  peek() {
    return this.items[0];
  }
  clear() {
    this.items = [];
  }
  isEmpty() {
    return this.items.length === 0;
  }
  size() {
    return this.items.length;
  }
  find(predicate) {
    return this.items.find(predicate);
  }
  toArray() {
    return [...this.items];
  }
  contains(predicate) {
    return this.items.some(predicate);
  }
}
//# sourceMappingURL=PriorityQueue.js.map