MCPcopy Create free account
hub / github.com/galacean/engine / _endLoop

Method _endLoop

packages/core/src/utils/DisorderedArray.ts:152–181  ·  view source on GitHub ↗
(swapFn: (e: T, idx: number) => void)

Source from the content-addressed store, hash-verified

150 }
151
152 private _endLoop(swapFn: (e: T, idx: number) => void): void {
153 if (--this._loopCounter !== 0) {
154 return;
155 }
156
157 if (this._blankCount) {
158 let from = 0;
159 let to = this.length - 1;
160 const elements = this._elements;
161 partition: do {
162 while (elements[from])
163 if (++from >= to) {
164 break partition;
165 }
166
167 while (!elements[to])
168 if (from >= --to) {
169 break partition;
170 }
171
172 const swapElement = elements[to];
173 swapFn?.(swapElement, from);
174 elements[from++] = swapElement;
175 elements[to--] = null;
176 } while (from < to);
177
178 this.length -= this._blankCount;
179 this._blankCount = 0;
180 }
181 }
182
183 private _endLoopAndClean(preEnd: number, elements: T[], swapFn: (element: T, index: number) => void): void {
184 if (--this._loopCounter !== 0) {

Callers 1

forEachMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected