MCPcopy Create free account
hub / github.com/esengine/esengine / bubbleUp

Method bubbleUp

packages/pathfinding/src/core/BinaryHeap.ts:107–123  ·  view source on GitHub ↗

* @zh 上浮操作 * @en Bubble up operation

(index: number)

Source from the content-addressed store, hash-verified

105 * @en Bubble up operation
106 */
107 private bubbleUp(index: number): void {
108 const item = this.heap[index];
109
110 while (index > 0) {
111 const parentIndex = Math.floor((index - 1) / 2);
112 const parent = this.heap[parentIndex];
113
114 if (this.compare(item, parent) >= 0) {
115 break;
116 }
117
118 this.heap[index] = parent;
119 index = parentIndex;
120 }
121
122 this.heap[index] = item;
123 }
124
125 /**
126 * @zh 下沉操作

Callers 2

pushMethod · 0.95
updateMethod · 0.95

Calls 1

compareMethod · 0.45

Tested by

no test coverage detected