Skip to content

Commit

Permalink
Check if Bitmap is empty in Contains
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Feb 9, 2024
1 parent aec9bd4 commit 0705c24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions roaring.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ func (rb *Bitmap) Maximum() uint32 {

// Contains returns true if the integer is contained in the bitmap
func (rb *Bitmap) Contains(x uint32) bool {
if rb.IsEmpty() {
return false
}
hb := highbits(x)
c := rb.highlowcontainer.getContainer(hb)
return c != nil && c.contains(lowbits(x))
Expand Down
3 changes: 3 additions & 0 deletions roaring64/roaring64.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ func (rb *Bitmap) Maximum() uint64 {

// Contains returns true if the integer is contained in the bitmap
func (rb *Bitmap) Contains(x uint64) bool {
if rb.IsEmpty() {
return false
}
hb := highbits(x)
c := rb.highlowcontainer.getContainer(hb)
return c != nil && c.Contains(lowbits(x))
Expand Down

0 comments on commit 0705c24

Please sign in to comment.