MCPcopy Create free account
hub / github.com/Effect-TS/effect / minHeapPush

Function minHeapPush

packages/effect/src/Graph.ts:4006–4018  ·  view source on GitHub ↗
(heap: Array<MinHeapEntry>, entry: MinHeapEntry)

Source from the content-addressed store, hash-verified

4004 self.priority < that.priority || (self.priority === that.priority && self.sequence < that.sequence)
4005
4006const minHeapPush = (heap: Array<MinHeapEntry>, entry: MinHeapEntry): void => {
4007 let index = heap.length
4008 heap.push(entry)
4009 while (index > 0) {
4010 const parent = (index - 1) >>> 1
4011 if (!minHeapLessThan(entry, heap[parent])) {
4012 break
4013 }
4014 heap[index] = heap[parent]
4015 index = parent
4016 }
4017 heap[index] = entry
4018}
4019
4020const minHeapPop = (heap: Array<MinHeapEntry>): MinHeapEntry | undefined => {
4021 const first = heap[0]

Callers 1

Graph.tsFile · 0.85

Calls 2

minHeapLessThanFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected