* 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)
| 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. |
no test coverage detected