-1 error
This commit is contained in:
parent
e0e5a72e90
commit
6b6ede656d
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user