From bcc8f03b95c35e8988f90e5fd3b58112fd634016 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 11 Apr 2025 16:51:37 -0700 Subject: Fix a bug in PopAll when the queue is full --- deque.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'deque.go') diff --git a/deque.go b/deque.go index 1208019..d4ef4be 100644 --- a/deque.go +++ b/deque.go @@ -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 - } } } } -- cgit v1.3.1