Add adds an item to the ring buffer
(item T)
| 20 | |
| 21 | // Add adds an item to the ring buffer |
| 22 | func (r *RingBuffer[T]) Add(item T) { |
| 23 | r.items[r.nextIndex] = item |
| 24 | r.nextIndex = (r.nextIndex + 1) % len(r.items) |
| 25 | if r.count < len(r.items) { |
| 26 | r.count++ |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // GetAll returns all items in the buffer, oldest first |
| 31 | func (b *RingBuffer[T]) GetAll() []T { |
no outgoing calls