MCPcopy
hub / github.com/TheAlgorithms/JavaScript / delete

Method delete

Data-Structures/Heap/MinPriorityQueue.js:112–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110 // deletes the highest priority value from the heap. The last
111 // element goes to ahead to first position and reorder heap
112 delete() {
113 // checks empty and one element array conditions
114 if (this.isEmpty()) return
115 if (this.size === 1) {
116 this.size--
117 return this.heap.pop()
118 }
119 const min = this.heap[1]
120 this.heap[1] = this.heap.pop()
121 this.size--
122 this.sink()
123 return min
124 }
125}
126
127export { MinPriorityQueue }

Callers 7

getMethod · 0.45
refreshMethod · 0.45
#removeCacheNodeMethod · 0.45
popMethod · 0.45
checkAnagramMapFunction · 0.45

Calls 3

isEmptyMethod · 0.95
sinkMethod · 0.95
popMethod · 0.45

Tested by

no test coverage detected