Add contains

This commit is contained in:
Joren 2024-06-18 17:38:01 +02:00
parent 5fc7f637b2
commit 62bafd9af7
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -73,3 +73,16 @@ func (rb *RingBuffer) GetLastPosition() int {
return rb.tail return rb.tail
} }
func (rb *RingBuffer) ContainsItem(item string) bool {
rb.mu.Lock()
defer rb.mu.Unlock()
for i := 0; i < rb.size; i++ {
index := (rb.head + i) % rb.size
if rb.buffer[index] == item {
return true
}
}
return false
}