This commit is contained in:
Joren 2024-06-18 17:49:07 +02:00
parent e0e5a72e90
commit 6b6ede656d
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -77,6 +77,10 @@ func (rb *RingBuffer) ContainsItem(item string) bool {
rb.mu.Lock() rb.mu.Lock()
defer rb.mu.Unlock() defer rb.mu.Unlock()
if rb.head == -1 {
return false
}
for i := 0; i < rb.size; i++ { for i := 0; i < rb.size; i++ {
index := (rb.head + i) % rb.size index := (rb.head + i) % rb.size
if rb.buffer[index] == item { if rb.buffer[index] == item {
@ -86,3 +90,4 @@ func (rb *RingBuffer) ContainsItem(item string) bool {
return false return false
} }