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