]> Sergey Matveev's repositories - btrtrc.git/blob - undirtied-chunks-iter.go
Drop support for go 1.20
[btrtrc.git] / undirtied-chunks-iter.go
1 package torrent
2
3 import (
4         "github.com/anacrolix/torrent/typed-roaring"
5 )
6
7 func iterBitmapUnsetInRange[T typedRoaring.BitConstraint](it *typedRoaring.Iterator[T], start, end T, f func(T)) {
8         it.AdvanceIfNeeded(start)
9         lastDirty := start - 1
10         for it.HasNext() {
11                 next := it.Next()
12                 if next >= end {
13                         break
14                 }
15                 for index := lastDirty + 1; index < next; index++ {
16                         f(index)
17                 }
18                 lastDirty = next
19         }
20         for index := lastDirty + 1; index < end; index++ {
21                 f(index)
22         }
23 }