(item: T)
| 6 | constructor(private readonly capacity: number) {} |
| 7 | |
| 8 | push(item: T): void { |
| 9 | if (this.count < this.capacity) { |
| 10 | this.buffer.push(item); |
| 11 | this.count++; |
| 12 | } else { |
| 13 | this.buffer[this.head] = item; |
| 14 | this.head = (this.head + 1) % this.capacity; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | clear(): void { |
| 19 | this.buffer = []; |
no outgoing calls