* Add an item to the buffer. If the buffer is full, * the oldest item will be evicted.
(item: T)
| 16 | * the oldest item will be evicted. |
| 17 | */ |
| 18 | add(item: T): void { |
| 19 | this.buffer[this.head] = item |
| 20 | this.head = (this.head + 1) % this.capacity |
| 21 | if (this.size < this.capacity) { |
| 22 | this.size++ |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Add multiple items to the buffer at once. |
no outgoing calls