v0.0.524
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m22s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m22s
This commit is contained in:
@@ -61,6 +61,9 @@ func (rb *RingBuffer[T]) At(i int) T {
|
||||
if i < 0 || i >= rb.size {
|
||||
panic("Index out of bounds")
|
||||
}
|
||||
if rb.size < rb.capacity {
|
||||
return rb.items[i]
|
||||
}
|
||||
return rb.items[(rb.head+i)%rb.capacity]
|
||||
}
|
||||
|
||||
@@ -68,6 +71,9 @@ func (rb *RingBuffer[T]) Get(i int) (T, bool) {
|
||||
if i < 0 || i >= rb.size {
|
||||
return *new(T), false
|
||||
}
|
||||
if rb.size < rb.capacity {
|
||||
return rb.items[i], true
|
||||
}
|
||||
return rb.items[(rb.head+i)%rb.capacity], true
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user