getBits sets all bits in the range [min, max], modulo the given step size.
(min, max, step uint)
| 342 | |
| 343 | // getBits sets all bits in the range [min, max], modulo the given step size. |
| 344 | func getBits(min, max, step uint) uint64 { |
| 345 | var bits uint64 |
| 346 | |
| 347 | // If step is 1, use shifts. |
| 348 | if step == 1 { |
| 349 | return ^(math.MaxUint64 << (max + 1)) & (math.MaxUint64 << min) |
| 350 | } |
| 351 | |
| 352 | // Else, use a simple loop. |
| 353 | for i := min; i <= max; i += step { |
| 354 | bits |= 1 << i |
| 355 | } |
| 356 | return bits |
| 357 | } |
| 358 | |
| 359 | // all returns all bits within the given bounds. (plus the star bit) |
| 360 | func all(r bounds) uint64 { |