| 38 |
|
|
| 39 |
|
namespace oopse{ |
| 40 |
|
|
| 41 |
< |
//use -1 to represent the wild card, it is easy and cheap to operate one integer (or index) instead of string |
| 41 |
> |
//use -1 to represent the wild card, it is easy and cheap to handle integer |
| 42 |
|
const int WildCard = -1; |
| 43 |
|
|
| 44 |
|
std::vector<std::vector<int> > ReplaceWildCard(int beginIndex, int endIndex, int nWildCard); |
| 55 |
|
* //0, -1, 2 |
| 56 |
|
* //0, 1, -1 |
| 57 |
|
* //-1, -1, 2 |
| 58 |
+ |
* //-1, 1, -1 |
| 59 |
|
* //0, -1, -1 |
| 60 |
|
* //-1, -1, -1 |
| 61 |
|
* @endcode |
| 106 |
|
std::vector<std::vector<int> > sequences; |
| 107 |
|
|
| 108 |
|
for (int i = 0; i <=nRecursive; i ++) { |
| 109 |
< |
firstPart.push_back( beginIndex + i); |
| 109 |
> |
firstPart.clear(); |
| 110 |
> |
for(int j = 0; j < i; ++j) { |
| 111 |
> |
firstPart.push_back(beginIndex + j); |
| 112 |
> |
} |
| 113 |
> |
firstPart.push_back(WildCard); |
| 114 |
|
secondPart = ReplaceWildCard(beginIndex + i + 1, endIndex, nWildCard - 1); |
| 115 |
|
sequences = adjoint(firstPart, secondPart); |
| 116 |
|
results.insert(results.end(), sequences.begin(), sequences.end()); |