UNPKG

269 BJavaScriptView Raw
1import { Heap } from "./Heap";
2export class MinHeap extends Heap {
3 constructor(key) {
4 super();
5 this.key = key;
6 }
7 compare(a, b) {
8 if (this.key) {
9 return a[this.key] <= b[this.key];
10 }
11 return a <= b;
12 }
13}