Skip to content

Commit 0705c24

Browse files
committed
Check if Bitmap is empty in Contains
1 parent aec9bd4 commit 0705c24

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

roaring.go

+3
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ func (rb *Bitmap) Maximum() uint32 {
819819

820820
// Contains returns true if the integer is contained in the bitmap
821821
func (rb *Bitmap) Contains(x uint32) bool {
822+
if rb.IsEmpty() {
823+
return false
824+
}
822825
hb := highbits(x)
823826
c := rb.highlowcontainer.getContainer(hb)
824827
return c != nil && c.contains(lowbits(x))

roaring64/roaring64.go

+3
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ func (rb *Bitmap) Maximum() uint64 {
313313

314314
// Contains returns true if the integer is contained in the bitmap
315315
func (rb *Bitmap) Contains(x uint64) bool {
316+
if rb.IsEmpty() {
317+
return false
318+
}
316319
hb := highbits(x)
317320
c := rb.highlowcontainer.getContainer(hb)
318321
return c != nil && c.Contains(lowbits(x))

0 commit comments

Comments
 (0)