* Retrieve the index with given raw data index.
(rawIndex: number)
| 535 | * Retrieve the index with given raw data index. |
| 536 | */ |
| 537 | indexOfRawIndex(rawIndex: number): number { |
| 538 | if (rawIndex >= this._rawCount || rawIndex < 0) { |
| 539 | return -1; |
| 540 | } |
| 541 | |
| 542 | if (!this._indices) { |
| 543 | return rawIndex; |
| 544 | } |
| 545 | |
| 546 | // Indices are ascending |
| 547 | const indices = this._indices; |
| 548 | |
| 549 | // If rawIndex === dataIndex |
| 550 | const rawDataIndex = indices[rawIndex]; |
| 551 | if (rawDataIndex != null && rawDataIndex < this._count && rawDataIndex === rawIndex) { |
| 552 | return rawIndex; |
| 553 | } |
| 554 | |
| 555 | let left = 0; |
| 556 | let right = this._count - 1; |
| 557 | while (left <= right) { |
| 558 | const mid = (left + right) / 2 | 0; |
| 559 | if (indices[mid] < rawIndex) { |
| 560 | left = mid + 1; |
| 561 | } |
| 562 | else if (indices[mid] > rawIndex) { |
| 563 | right = mid - 1; |
| 564 | } |
| 565 | else { |
| 566 | return mid; |
| 567 | } |
| 568 | } |
| 569 | return -1; |
| 570 | } |
| 571 | |
| 572 | getIndices(): ArrayLike<number> { |
| 573 | let newIndices; |
no outgoing calls
no test coverage detected