MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / poll

Method poll

src/data-structures/heap/MinHeapAdhoc.js:22–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20 }
21
22 poll() {
23 if (this.heap.length === 0) return undefined;
24 const top = this.heap[0];
25 this.heap[0] = this.heap[this.heap.length - 1];
26 this.heap.pop();
27 this.heapifyDown();
28 return top;
29 }
30
31 isEmpty() {
32 return this.heap.length === 0;

Callers

nothing calls this directly

Calls 2

heapifyDownMethod · 0.95
popMethod · 0.80

Tested by

no test coverage detected