| 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) { |