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

Method forEachAndClean

packages/core/src/utils/DisorderedArray.ts:122–131  ·  view source on GitHub ↗

* Loop through all elements and clean up the blank elements. * @param callbackFn - The callback function * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)

(callbackFn: (element: T, index: number) => void, swapFn?: (element: T, index: number) => void)

Source from the content-addressed store, hash-verified

120 * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
121 */
122 forEachAndClean(callbackFn: (element: T, index: number) => void, swapFn?: (element: T, index: number) => void): void {
123 this._startLoop();
124 const preEnd = this.length;
125 const elements = this._elements;
126 for (let i = 0, n = preEnd; i < n; i++) {
127 const element = elements[i];
128 element && callbackFn(element, i);
129 }
130 this._endLoopAndClean(preEnd, elements, swapFn);
131 }
132
133 /**
134 * Sort the array.

Callers 1

callScriptOnStartMethod · 0.80

Calls 2

_startLoopMethod · 0.95
_endLoopAndCleanMethod · 0.95

Tested by

no test coverage detected