SizesForBitLen computes the number of words and last bits used for the requested bit array size.
(bitLen uint)
| 310 | // SizesForBitLen computes the number of words and last bits used for |
| 311 | // the requested bit array size. |
| 312 | func SizesForBitLen(bitLen uint) (uint, uint64) { |
| 313 | // This computes ceil(bitLen / numBitsPerWord). |
| 314 | numWords := (bitLen + numBitsPerWord - 1) / numBitsPerWord |
| 315 | lastBitsUsed := uint64(bitLen % numBitsPerWord) |
| 316 | if lastBitsUsed == 0 { |
| 317 | lastBitsUsed = numBitsPerWord |
| 318 | } |
| 319 | return numWords, lastBitsUsed |
| 320 | } |
| 321 | |
| 322 | // Parse parses a bit array from the specified string. |
| 323 | func Parse(s string) (res BitArray, err error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…