* Map any index into the range 0 <= index < 2*capacity.
(index: number)
| 48 | * Map any index into the range 0 <= index < 2*capacity. |
| 49 | */ |
| 50 | protected wrap(index: number) { |
| 51 | // don't trust % on negative numbers |
| 52 | while (index < 0) { |
| 53 | index += this.doubledCapacity; |
| 54 | } |
| 55 | return index % this.doubledCapacity; |
| 56 | } |
| 57 | |
| 58 | protected get(index: number) { |
| 59 | if (index < 0) { |