Compare commits
3 Commits
7d17744239
...
v1.0.2
Author | SHA1 | Date | |
---|---|---|---|
6b6ede656d
|
|||
e0e5a72e90
|
|||
62bafd9af7
|
@ -73,3 +73,21 @@ 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()
|
||||||
|
|
||||||
|
if rb.head == -1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < rb.size; i++ {
|
||||||
|
index := (rb.head + i) % rb.size
|
||||||
|
if rb.buffer[index] == item {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user