11 #ifndef __COMBINATION_H__
12 #define __COMBINATION_H__
17 template <
class B
idIt>
20 bool boolmarked =
false;
26 BidIt tmp_r_end = r_end;
29 for (BidIt r_it1 = tmp_r_end; r_it1 != r_begin || r_it1 == r_begin; --r_it1, --n_it1) {
30 if (*r_it1 == *n_it1) {
42 if (boolmarked ==
true) {
45 for (BidIt n_it2 = n_begin; n_it2 != n_end; ++n_it2)
46 if (*r_marked == *n_it2) {
51 BidIt n_it3 = ++n_marked;
52 for (BidIt r_it2 = r_marked; r_it2 != r_end; ++r_it2, ++n_it3) {
57 for (BidIt n_it4 = n_begin; n_it4 != n_end; ++n_it4)
58 if (*r_it1 == *n_it4) {
69 template <
class B
idIt,
class Prediate>
71 inline bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end, Prediate Equal) {
72 bool boolmarked =
false;
78 BidIt tmp_r_end = r_end;
81 for (BidIt r_it1 = tmp_r_end; r_it1 != r_begin || r_it1 == r_begin; --r_it1, --n_it1) {
82 if (Equal(*r_it1, *n_it1)) {
94 if (boolmarked ==
true) {
97 for (BidIt n_it2 = n_begin; n_it2 != n_end; ++n_it2)
98 if (Equal(*r_marked, *n_it2)) {
103 BidIt n_it3 = ++n_marked;
104 for (BidIt r_it2 = r_marked; r_it2 != r_end; ++r_it2, ++n_it3) {
109 for (BidIt n_it4 = n_begin; n_it4 != n_end; ++n_it4)
110 if (Equal(*r_it1, *n_it4)) {
121 template <
class B
idIt>
128 BidIt tmp_n_end = n_end;
134 for (BidIt n_it1 = tmp_n_end; n_it1 != n_begin || n_it1 == n_begin; --n_it1) {
135 if (*r_it1 == *n_it1) {
142 BidIt n_it2 = n_marked;
144 BidIt tmp_r_end = r_end;
147 for (BidIt r_it2 = r_marked; r_it2 != r_begin || r_it2 == r_begin; --r_it2, --n_it2) {
148 if (*r_it2 == *n_it2) {
149 if (r_it2 == r_begin && !(*r_it2 == *n_begin)) {
150 for (BidIt n_it3 = n_begin; n_it3 != n_end; ++n_it3) {
151 if (*r_it2 == *n_it3) {
157 for (BidIt r_it3 = tmp_r_end; (r_it3 != r_begin || r_it3 == r_begin) && r_it3 != marked;
164 }
else if (r_it2 == r_begin && *r_it2 == *n_begin) {
171 for (BidIt n_it5 = n_begin; n_it5 != n_end; ++n_it5) {
172 if (*r_it2 == *n_it5) {
177 for (BidIt r_it4 = tmp_r_end; (r_it4 != r_begin || r_it4 == r_begin) && r_it4 != marked; --r_it4, --n_it6) {
189 template <
class B
idIt,
class Prediate>
191 inline bool prev_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end, Prediate Equal) {
196 BidIt tmp_n_end = n_end;
202 for (BidIt n_it1 = tmp_n_end; n_it1 != n_begin || n_it1 == n_begin; --n_it1) {
203 if (Equal(*r_it1, *n_it1)) {
210 BidIt n_it2 = n_marked;
212 BidIt tmp_r_end = r_end;
215 for (BidIt r_it2 = r_marked; r_it2 != r_begin || r_it2 == r_begin; --r_it2, --n_it2) {
216 if (Equal(*r_it2, *n_it2)) {
217 if (r_it2 == r_begin && !Equal(*r_it2, *n_begin)) {
218 for (BidIt n_it3 = n_begin; n_it3 != n_end; ++n_it3) {
219 if (Equal(*r_it2, *n_it3)) {
225 for (BidIt r_it3 = tmp_r_end; (r_it3 != r_begin || r_it3 == r_begin) && r_it3 != marked;
232 }
else if (r_it2 == r_begin && Equal(*r_it2, *n_begin)) {
239 for (BidIt n_it5 = n_begin; n_it5 != n_end; ++n_it5) {
240 if (Equal(*r_it2, *n_it5)) {
245 for (BidIt r_it4 = tmp_r_end; (r_it4 != r_begin || r_it4 == r_begin) && r_it4 != marked; --r_it4, --n_it6) {
257 template <
class RanIt,
class Func>
260 RanIt nbegin, RanIt nend,
int n_column, RanIt rbegin, RanIt rend,
int r_column,
int loop, Func
func) {
261 int r_size = rend - rbegin;
263 int localloop =
loop;
264 int local_n_column = n_column;
267 if (r_column > (r_size - 1)) {
273 for (
int i = 0;
i <=
loop; ++
i) {
275 for (
int cnt = 0; cnt < r_column; ++cnt) {
280 for (
int cnt2 = 0; cnt2 < n_column +
i; ++cnt2) {