1 #ifndef _CombinationGenerator_H_
2 #define _CombinationGenerator_H_
33 if (prev_permutation(sorted.begin(), sorted.end())) {
34 sort(sorted.begin(), sorted.end());
39 std::vector<std::vector<PartitionGenerator::Partition> >
partitions =
43 for (std::vector<PartitionGenerator::Partition>::const_iterator idiv =
partitions[numberOfCollections - 1].
begin();
44 idiv !=
partitions[numberOfCollections - 1].end();
47 std::vector<Combination> subCombinations = this->
combinations(data, partition);
48 for (
typename std::vector<Combination>::const_iterator iComb = subCombinations.begin();
49 iComb != subCombinations.end();
66 for (PartitionGenerator::Partition::const_iterator iSize = partition.begin(); iSize != partition.end(); iSize++) {
69 if (nElts !=
data.size())
74 if (prev_permutation(sortedData.begin(), sortedData.end())) {
75 sort(sortedData.begin(), sortedData.end());
80 comb.push_back(sortedData);
81 if (partition.size() == 1) {
86 std::stack<Combination> cStack;
93 sort(sortedPartition.begin(), sortedPartition.end(), std::greater_equal<int>());
95 while (!cStack.empty()) {
105 int k = sortedPartition.size() - combination.size();
107 for (
int iColl = 0; iColl !=
k; iColl++) {
108 size += sortedPartition[iColl];
111 biPartition[0] =
size;
112 biPartition[1] = sortedPartition[
k];
115 for (
typename std::vector<Combination>::const_iterator iComb = subCombinations.begin();
116 iComb != subCombinations.end();
119 if (combination.size() > 1) {
120 if ((*iComb)[1].size() == combination[1].size()) {
122 adjBins.push_back((*iComb)[1][0]);
123 adjBins.push_back(combination[1][0]);
126 if (prev_permutation(adjBins.begin(), adjBins.end()))
133 typename Combination::const_iterator it = combination.begin();
135 for (; it != combination.end(); it++) {
136 merged.push_back(*it);
141 if (merged.size() == sortedPartition.size()) {
157 if (prev_permutation(sorted.begin(), sorted.end())) {
158 sort(sorted.begin(), sorted.end());
164 for (std::vector<PartitionGenerator::Partition>::const_iterator idiv =
partitions.begin(); idiv !=
partitions.end();
168 std::vector<Combination> subCombinations = this->
combinations(data, partition);
169 for (
typename std::vector<Combination>::const_iterator iComb = subCombinations.begin();
170 iComb != subCombinations.end();
184 std::stack<Combination> cStack;
192 while (!cStack.empty()) {
199 for (
typename std::vector<Combination>::const_iterator iComb = subCombinations.begin();
200 iComb != subCombinations.end();
203 second.push_back((*iComb)[1][0]);
207 bool ordered = !prev_permutation(
second.begin(),
second.end());
212 if ((*iComb)[0].size() ==
second.size()) {
214 adjBins.push_back((*iComb)[0][0]);
215 adjBins.push_back(
second[0]);
218 if (prev_permutation(adjBins.begin(), adjBins.end()))
223 stored.push_back((*iComb)[0]);
226 if (stored[0].
size() == sizeFirst) {
241 for (
typename Collection::const_iterator
i =
data.begin();
i !=
data.end();
i++) {
246 typename Collection::const_iterator
j =
data.begin();
247 for (;
j !=
i;
j++) {
251 for (;
j !=
data.end();
j++) {
254 comb.push_back(coll);