* Constructs a `RingBuffer`. * @param capacity The number of items that the buffer can accomodate.
(public capacity: number)
| 34 | * @param capacity The number of items that the buffer can accomodate. |
| 35 | */ |
| 36 | constructor(public capacity: number) { |
| 37 | if (capacity == null) { |
| 38 | throw new RangeError('Can\'t create a ring buffer of unknown capacity.'); |
| 39 | } |
| 40 | if (capacity < 1) { |
| 41 | throw new RangeError('Can\'t create ring buffer of capacity < 1.'); |
| 42 | } |
| 43 | this.data = new Array<T>(capacity); |
| 44 | this.doubledCapacity = 2 * capacity; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Map any index into the range 0 <= index < 2*capacity. |
nothing calls this directly
no outgoing calls
no test coverage detected