diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-11 16:51:37 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-04-11 16:51:37 -0700 |
| commit | bcc8f03b95c35e8988f90e5fd3b58112fd634016 (patch) | |
| tree | a07e5254312bb04b3f4e78792c0a6c87f79662fa /deque.go | |
| parent | 43e0f85d803045a073e2c78063bd8bc944d0fe68 (diff) | |
| download | deque-bcc8f03b95c35e8988f90e5fd3b58112fd634016.tar.zst | |
Fix a bug in PopAll when the queue is full
Diffstat (limited to 'deque.go')
| -rw-r--r-- | deque.go | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -182,15 +182,10 @@ func (q *Deque[T]) PopAll() func(func(T) bool) { n := len(q.buf) q.buf = q.buf[:0] return func(yield func(T) bool) { - endIdx := q.toPhysicalIdx(n) - for i := q.head; ; { - if !yield(q.buf[:cap(q.buf)][i]) { + for i := range n { + if !yield(q.buf[:cap(q.buf)][q.toPhysicalIdx(i)]) { return } - i = q.wrapAdd(i, 1) - if i == endIdx { - break - } } } } |
