12 #ifndef __COMBINATION_H__
13 #define __COMBINATION_H__
20 template <
class B
idIt>
23 BidIt r_begin, BidIt r_end)
26 bool boolmarked=
false;
33 BidIt tmp_r_end=r_end;
36 for(BidIt r_it1=tmp_r_end; r_it1!=r_begin || r_it1==r_begin; --r_it1,--n_it1)
57 for (BidIt n_it2=n_begin;n_it2!=n_end;++n_it2)
58 if(*r_marked==*n_it2) {n_marked=n_it2;
break;}
61 BidIt n_it3=++n_marked;
62 for (BidIt r_it2=r_marked;r_it2!=r_end;++r_it2,++n_it3)
68 for(BidIt n_it4=n_begin; n_it4!=n_end; ++n_it4)
81 template <
class B
idIt,
class Prediate>
91 bool boolmarked=
false;
98 BidIt tmp_r_end=r_end;
101 for(BidIt r_it1=tmp_r_end; r_it1!=r_begin || r_it1==r_begin; --r_it1,--n_it1)
103 if( Equal( *r_it1, *n_it1) )
122 for (BidIt n_it2=n_begin;n_it2!=n_end;++n_it2)
123 if( Equal( *r_marked, *n_it2) ) {n_marked=n_it2;
break;}
126 BidIt n_it3=++n_marked;
127 for (BidIt r_it2=r_marked;r_it2!=r_end;++r_it2,++n_it3)
133 for(BidIt n_it4=n_begin; n_it4!=n_end; ++n_it4)
134 if( Equal(*r_it1, *n_it4) )
147 template <
class B
idIt>
150 BidIt r_begin, BidIt r_end)
158 BidIt tmp_n_end=n_end;
164 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
174 BidIt n_it2=n_marked;
177 BidIt tmp_r_end=r_end;
180 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
184 if(r_it2==r_begin&& !(*r_it2==*n_begin) )
186 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
195 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
203 else if(r_it2==r_begin&&*r_it2==*n_begin)
212 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
220 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
234 template <
class B
idIt,
class Prediate>
249 BidIt tmp_n_end=n_end;
255 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
257 if( Equal(*r_it1, *n_it1) )
265 BidIt n_it2=n_marked;
268 BidIt tmp_r_end=r_end;
271 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
273 if( Equal(*r_it2, *n_it2) )
275 if(r_it2==r_begin&& !Equal(*r_it2, *n_begin) )
277 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
279 if(Equal(*r_it2, *n_it3))
286 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
294 else if(r_it2==r_begin&&Equal(*r_it2, *n_begin))
303 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
305 if(Equal(*r_it2, *n_it5))
311 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
325 template <
class RanIt,
class Func>
328 RanIt rbegin, RanIt rend,
int r_column,
int loop, Func
func)
331 int r_size=rend-rbegin;
335 int local_n_column=n_column;
338 if(r_column>(r_size-1))
349 for(
int cnt=0;cnt<r_column;++cnt)
355 for(
int cnt2=0;cnt2<n_column+
i;++cnt2)
365 rbegin,rend,r_column+1,localloop,func);
void recursive_combination(RanIt nbegin, RanIt nend, int n_column, RanIt rbegin, RanIt rend, int r_column, int loop, Func func)
bool prev_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)