| 241 | } |
| 242 | |
| 243 | std::vector<int> Next() { |
| 244 | std::vector<int> permutation(next_permutation_); |
| 245 | |
| 246 | // Generates next permutation, if available. |
| 247 | bool carry = true; |
| 248 | for (int i = next_permutation_.size() - 1; i >= 0; i--) { |
| 249 | if (carry) { |
| 250 | next_permutation_[i] = next_permutation_[i] + 1; |
| 251 | } |
| 252 | if (next_permutation_[i] == columns_[i]->FeatureCount(batch_index_)) { |
| 253 | next_permutation_[i] = 0; |
| 254 | } else { |
| 255 | carry = false; |
| 256 | break; |
| 257 | } |
| 258 | } |
| 259 | has_next_ = !carry; |
| 260 | return permutation; |
| 261 | } |
| 262 | |
| 263 | bool HasNext() { return has_next_; } |
| 264 | |