| 2189 | } |
| 2190 | |
| 2191 | const increasing = (sources: Int32Array): Array<number> => { |
| 2192 | const before = new Int32Array(sources.length) |
| 2193 | const run: Array<number> = [] |
| 2194 | for (let index = 0; index < sources.length; index++) { |
| 2195 | const value = sources[index]! |
| 2196 | if (value === 0) continue |
| 2197 | let low = 0 |
| 2198 | let high = run.length |
| 2199 | while (low < high) { |
| 2200 | const mid = (low + high) >> 1 |
| 2201 | if (sources[run[mid]!]! < value) low = mid + 1 |
| 2202 | else high = mid |
| 2203 | } |
| 2204 | before[index] = low > 0 ? run[low - 1]! : -1 |
| 2205 | run[low] = index |
| 2206 | } |
| 2207 | for (let index = run.length - 1, at = run[index]; index >= 0; index--) { |
| 2208 | run[index] = at! |
| 2209 | at = before[at!] |
| 2210 | } |
| 2211 | return run |
| 2212 | } |
| 2213 | |
| 2214 | /** @internal */ |
| 2215 | export interface Root { |