2022-05-09 10:51:01 +08:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/anacrolix/torrent/typed-roaring"
|
|
|
|
)
|
|
|
|
|
2022-05-11 09:20:52 +08:00
|
|
|
func iterBitmapUnsetInRange[T typedRoaring.BitConstraint](it *typedRoaring.Iterator[T], start, end T, f func(T)) {
|
|
|
|
it.AdvanceIfNeeded(start)
|
|
|
|
lastDirty := start - 1
|
2022-05-09 10:51:01 +08:00
|
|
|
for it.HasNext() {
|
|
|
|
next := it.Next()
|
2022-05-11 09:20:52 +08:00
|
|
|
if next >= end {
|
2022-05-09 10:51:01 +08:00
|
|
|
break
|
|
|
|
}
|
|
|
|
for index := lastDirty + 1; index < next; index++ {
|
2022-05-11 09:20:52 +08:00
|
|
|
f(index)
|
2022-05-09 10:51:01 +08:00
|
|
|
}
|
|
|
|
lastDirty = next
|
|
|
|
}
|
2022-05-11 09:20:52 +08:00
|
|
|
for index := lastDirty + 1; index < end; index++ {
|
|
|
|
f(index)
|
2022-05-09 10:51:01 +08:00
|
|
|
}
|
|
|
|
}
|