* Removes and returns a specific item in the buffer, and moves the last item * to the vacated slot. This is useful for implementing a shuffling stream. * Note that this operation necessarily scrambles the original order. * * @param relativeIndex: the index of the item to remove, relativ
(relativeIndex: number)
| 165 | * storage). |
| 166 | */ |
| 167 | shuffleExcise(relativeIndex: number): T { |
| 168 | if (this.isEmpty()) { |
| 169 | throw new RangeError('Ring buffer is empty.'); |
| 170 | } |
| 171 | const index = this.wrap(this.begin + relativeIndex); |
| 172 | const result = this.get(index); |
| 173 | this.set(index, this.pop()); |
| 174 | return result; |
| 175 | } |
| 176 | } |
no test coverage detected