aboutsummaryrefslogtreecommitdiffstats
path: root/deque.go
diff options
context:
space:
mode:
Diffstat (limited to 'deque.go')
-rw-r--r--deque.go9
1 files changed, 2 insertions, 7 deletions
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
- }
}
}
}