Rand generates a random bit array of the specified length.
(rng *rand.Rand, bitLen uint)
| 525 | |
| 526 | // Rand generates a random bit array of the specified length. |
| 527 | func Rand(rng *rand.Rand, bitLen uint) BitArray { |
| 528 | d := MakeZeroBitArray(bitLen) |
| 529 | for i := range d.words { |
| 530 | d.words[i] = rng.Uint64() |
| 531 | } |
| 532 | if len(d.words) > 0 { |
| 533 | d.words[len(d.words)-1] <<= (numBitsPerWord - d.lastBitsUsed) |
| 534 | } |
| 535 | return d |
| 536 | } |
| 537 | |
| 538 | // Next returns the next possible bit array in lexicographic order. |
| 539 | // The backing array of words is shared if possible. |
nothing calls this directly
no test coverage detected