forked from RoaringBitmap/roaring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiter.go
More file actions
29 lines (27 loc) · 721 Bytes
/
iter.go
File metadata and controls
29 lines (27 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package roaring
// Values returns an iterator that yields the elements of the bitmap in
// increasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Values(b *Bitmap) func(func(uint32) bool) {
return func(yield func(uint32) bool) {
it := b.Iterator()
for it.HasNext() {
if !yield(it.Next()) {
return
}
}
}
}
// Backward returns an iterator that yields the elements of the bitmap in
// decreasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Backward(b *Bitmap) func(func(uint32) bool) {
return func(yield func(uint32) bool) {
it := b.ReverseIterator()
for it.HasNext() {
if !yield(it.Next()) {
return
}
}
}
}