Generates random digits_, return true if successful. Returns false if the random sequence is over.
| 62 | // Generates random digits_, return true if successful. |
| 63 | // Returns false if the random sequence is over. |
| 64 | bool StringGenerator::RandomDigits() { |
| 65 | if (--nrandom_ <= 0) |
| 66 | return false; |
| 67 | |
| 68 | std::uniform_int_distribution<int> random_len(0, maxlen_); |
| 69 | std::uniform_int_distribution<int> random_alphabet_index( |
| 70 | 0, static_cast<int>(alphabet_.size()) - 1); |
| 71 | |
| 72 | // Pick length. |
| 73 | int len = random_len(rng_); |
| 74 | digits_.resize(len); |
| 75 | for (int i = 0; i < len; i++) |
| 76 | digits_[i] = random_alphabet_index(rng_); |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | // Returns the next string in the iteration, which is the one |
| 81 | // currently described by digits_. Calls IncrementDigits |