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)
159 BidIt tmp_n_end=n_end;
165 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
175 BidIt n_it2=n_marked;
178 BidIt tmp_r_end=r_end;
181 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
185 if(r_it2==r_begin&& !(*r_it2==*n_begin) )
187 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
196 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
204 else if(r_it2==r_begin&&*r_it2==*n_begin)
213 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
221 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
235 template <
class B
idIt,
class Prediate>
251 BidIt tmp_n_end=n_end;
257 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
259 if( Equal(*r_it1, *n_it1) )
267 BidIt n_it2=n_marked;
270 BidIt tmp_r_end=r_end;
273 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
275 if( Equal(*r_it2, *n_it2) )
277 if(r_it2==r_begin&& !Equal(*r_it2, *n_begin) )
279 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
281 if(Equal(*r_it2, *n_it3))
288 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
296 else if(r_it2==r_begin&&Equal(*r_it2, *n_begin))
305 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
307 if(Equal(*r_it2, *n_it5))
313 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
327 template <
class RanIt,
class Func>
330 RanIt rbegin, RanIt rend,
int r_column,
int loop, Func func)
333 int r_size=rend-rbegin;
337 int local_n_column=n_column;
340 if(r_column>(r_size-1))
351 for(
int cnt=0;cnt<r_column;++cnt)
357 for(
int cnt2=0;cnt2<n_column+
i;++cnt2)
367 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)