| 270 | //------------------------------------------------------------------------------ |
| 271 | |
| 272 | template<class T> static void CombinationsImpl(const vector<T> &elems, const u_int size, vector<vector<T> > &result, |
| 273 | vector<T> &tmp, const u_int start, const u_int end, const u_int index) { |
| 274 | if (index == size) { |
| 275 | // Done |
| 276 | result.push_back(tmp); |
| 277 | } else { |
| 278 | for (u_int i = start; i <= end && (end - i + 1 >= size - index); i++) { |
| 279 | tmp[index] = elems[i]; |
| 280 | CombinationsImpl(elems, size, result, tmp, i + 1, end, index + 1); |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | template<class T> static void Combinations(const vector<T> &elems, const u_int size, vector<vector<T> > &result) { |
| 286 | vector<T> tmp(size); |
no test coverage detected