* Loop through all 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)
| 105 | * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true) |
| 106 | */ |
| 107 | forEach(callbackFn: (element: T, index: number) => void, swapFn?: (element: T, index: number) => void): void { |
| 108 | this._startLoop(); |
| 109 | const elements = this._elements; |
| 110 | for (let i = 0, n = this.length; i < n; i++) { |
| 111 | const element = elements[i]; |
| 112 | element && callbackFn(element, i); |
| 113 | } |
| 114 | this._endLoop(swapFn); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Loop through all elements and clean up the blank elements. |