Skip to content

Commit

Permalink
Added working version
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Mar 17, 2017
1 parent 06961f1 commit dd6fd8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bitmapcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ func clz(i uint64) int {
}

func (bc *bitmapContainer) maximum() uint16 {
for i := len(bc.bitmap) - 1; i > 0; i += 1 {
w := bc.bitmap[i]
for i := len(bc.bitmap) ; i > 0; i -= 1 {
w := bc.bitmap[i - 1]
if w != 0 {
r := clz(w)
return uint16(i*64 + 63 - r)
return uint16((i-1)*64 + 63 - r)
}
}
return uint16(0)
Expand Down
10 changes: 5 additions & 5 deletions roaring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
)

func testFirstLast(t *testing.T) {
func TestFirstLast(t *testing.T) {
bm := New()
bm.AddInt(2)
bm.AddInt(4)
Expand All @@ -23,14 +23,14 @@ func testFirstLast(t *testing.T) {
t.FailNow()
}
i := 1 << 5
for ; i < (1 << 14); i += 1 {
for ; i < (1 << 17); i += 1 {
bm.AddInt(i)
if 2 != bm.Minimum() {
t.Errorf("bad minimum")
t.FailNow()
}
if uint32(i) != bm.Maximum() {
t.Errorf("bad maximum")
t.Errorf("bad maximum",i,bm.Maximum())
t.FailNow()
}
}
Expand All @@ -39,8 +39,8 @@ func testFirstLast(t *testing.T) {
t.Errorf("bad minimum")
t.FailNow()
}
if uint32(i) != bm.Maximum() {
t.Errorf("bad maximum")
if uint32(i-1) != bm.Maximum() {
t.Errorf("bad maximum",i,bm.Maximum())
t.FailNow()
}
}
Expand Down

0 comments on commit dd6fd8e

Please sign in to comment.