14 #ifndef __COMBINATION_H__
15 #define __COMBINATION_H__
22 template <
class B
idIt>
25 BidIt r_begin, BidIt r_end)
28 bool boolmarked=
false;
35 BidIt tmp_r_end=r_end;
38 for(BidIt r_it1=tmp_r_end; r_it1!=r_begin || r_it1==r_begin; --r_it1,--n_it1)
59 for (BidIt n_it2=n_begin;n_it2!=n_end;++n_it2)
60 if(*r_marked==*n_it2) {n_marked=n_it2;
break;}
63 BidIt n_it3=++n_marked;
64 for (BidIt r_it2=r_marked;r_it2!=r_end;++r_it2,++n_it3)
70 for(BidIt n_it4=n_begin; n_it4!=n_end; ++n_it4)
83 template <
class B
idIt,
class Prediate>
93 bool boolmarked=
false;
100 BidIt tmp_r_end=r_end;
103 for(BidIt r_it1=tmp_r_end; r_it1!=r_begin || r_it1==r_begin; --r_it1,--n_it1)
105 if( Equal( *r_it1, *n_it1) )
124 for (BidIt n_it2=n_begin;n_it2!=n_end;++n_it2)
125 if( Equal( *r_marked, *n_it2) ) {n_marked=n_it2;
break;}
128 BidIt n_it3=++n_marked;
129 for (BidIt r_it2=r_marked;r_it2!=r_end;++r_it2,++n_it3)
135 for(BidIt n_it4=n_begin; n_it4!=n_end; ++n_it4)
136 if( Equal(*r_it1, *n_it4) )
149 template <
class B
idIt>
152 BidIt r_begin, BidIt r_end)
161 BidIt tmp_n_end=n_end;
167 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
177 BidIt n_it2=n_marked;
180 BidIt tmp_r_end=r_end;
183 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
187 if(r_it2==r_begin&& !(*r_it2==*n_begin) )
189 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
198 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
206 else if(r_it2==r_begin&&*r_it2==*n_begin)
215 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
223 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
237 template <
class B
idIt,
class Prediate>
253 BidIt tmp_n_end=n_end;
259 for(BidIt n_it1=tmp_n_end; n_it1!=n_begin || n_it1==n_begin ; --n_it1)
261 if( Equal(*r_it1, *n_it1) )
269 BidIt n_it2=n_marked;
272 BidIt tmp_r_end=r_end;
275 for(BidIt r_it2=r_marked; r_it2!=r_begin || r_it2==r_begin; --r_it2,--n_it2)
277 if( Equal(*r_it2, *n_it2) )
279 if(r_it2==r_begin&& !Equal(*r_it2, *n_begin) )
281 for(BidIt n_it3=n_begin;n_it3!=n_end;++n_it3)
283 if(Equal(*r_it2, *n_it3))
290 for(BidIt r_it3=tmp_r_end; (r_it3!=r_begin || r_it3==r_begin) &&r_it3!=marked; --r_it3,--n_it4)
298 else if(r_it2==r_begin&&Equal(*r_it2, *n_begin))
307 for(BidIt n_it5=n_begin;n_it5!=n_end;++n_it5)
309 if(Equal(*r_it2, *n_it5))
315 for(BidIt r_it4=tmp_r_end; (r_it4!=r_begin || r_it4==r_begin) &&r_it4!=marked; --r_it4,--n_it6)
329 template <
class RanIt,
class Func>
332 RanIt rbegin, RanIt rend,
int r_column,
int loop, Func func)
335 int r_size=rend-rbegin;
339 int local_n_column=n_column;
342 if(r_column>(r_size-1))
349 for(
int i=0;i<=loop;++i)
353 for(
int cnt=0;cnt<r_column;++cnt)
359 for(
int cnt2=0;cnt2<n_column+i;++cnt2)
369 rbegin,rend,r_column+1,localloop,func);