File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ func (s *Set) Max() int {
138138 }
139139 d := s .data
140140 i := len (d ) - 1
141- return i << shift + 63 - bits .LeadingZeros64 (d [i ])
141+ return i << shift + bits .Len64 (d [i ]) - 1
142142}
143143
144144// Size returns the number of elements in the set.
@@ -199,7 +199,7 @@ func (s *Set) Prev(m int) int {
199199 return - 1
200200 }
201201 i := len - 1
202- if max := i << shift + 63 - bits .LeadingZeros64 (d [i ]); m > max {
202+ if max := i << shift + bits .Len64 (d [i ]) - 1 ; m > max {
203203 return max
204204 }
205205 i = m >> shift
@@ -212,7 +212,7 @@ func (s *Set) Prev(m int) int {
212212 if w == 0 {
213213 return - 1
214214 }
215- return i << shift + 63 - bits .LeadingZeros64 (w )
215+ return i << shift + bits .Len64 (w ) - 1
216216}
217217
218218// Visit calls the do function for each element of s in numerical order.
@@ -556,7 +556,7 @@ func nextPow2(n int) (p int) {
556556 if n <= 0 {
557557 return 1
558558 }
559- if k := 64 - bits .LeadingZeros64 (uint64 (n )); k < bitsPerWord - 1 {
559+ if k := bits .Len64 (uint64 (n )); k < bitsPerWord - 1 {
560560 return 1 << uint (k )
561561 }
562562 return MaxInt
You can’t perform that action at this time.
0 commit comments