112 Item *aux=
new Item[size];
114 for(
int k=0;k<count;k++)
131 operator[](k)=init[k];
137 if(v!=NULL)
delete [] v;
149 if(right<0 || right>count-1) right=count-1;
150 if(left<0 || left>right) left=0;
155 if(v[mid]==i)
return mid;
156 if(v[mid]<i) left=mid+1;
160 for(
int k=0;k<count;k++)
175 QuickSort(0,count-1);
176 Insertion(0,count-1);
182 for(
int k=0;k<count;k++)
184 QuickSortIdx(0,count-1);
191 if(end>count-1 || end<0) end=count-1;
194 QuickSort(start,end);
195 Insertion(start,end);
204 Exch((start+end)>>1,end-1);
206 if(v[end-1]<v[start]) Exch(end-1,start);
207 if(v[end]<v[start]) Exch(end,start);
208 if(v[end]<v[end-1]) Exch(end,end-1);
219 while(a<v[--j] && j>start);
225 QuickSort(start-1,i-1);
226 QuickSort(i+1,end+1);
234 for(i=end; i>start; i--)
238 for(i=start+2; i<=end; i++) {
254 if(v[(*idx)[end]]<v[(*idx)[start]]) ExchIdx(end,start);
255 }
else if(end-start==2) {
256 if(v[(*idx)[end-1]]<v[(*idx)[start]]) ExchIdx(end-1,start);
257 if(v[(*idx)[end]]<v[(*idx)[start]]) ExchIdx(end,start);
258 if(v[(*idx)[end]]<v[(*idx)[end-1]]) ExchIdx(end,end-1);
261 ExchIdx((start+end)>>1,end-1);
263 if(v[(*idx)[end-1]]<v[(*idx)[start]]) ExchIdx(end-1,start);
264 if(v[(*idx)[end]]<v[(*idx)[start]]) ExchIdx(end,start);
265 if(v[(*idx)[end]]<v[(*idx)[end-1]]) ExchIdx(end,end-1);
273 Item a=v[(*idx)[end]];
275 while(v[(*idx)[++i]]<a);
276 while(a<v[(*idx)[--j]] && j>start);
282 if(i>start) QuickSortIdx(start-1,i-1);
283 if(i<end) QuickSortIdx(i+1,end+1);
291 for(
int k=count-1;k>0;k--)
300 for(w=0,k=0;w<count;w++) {
311 for(
int j=0;j<count;j++)
319 for(
int k=0;k<count;k++)
329 for(k=i;k<count-1;k++) {
341 for(k=v.
Count()-1;k>=0;k--)
353 for(k=v.
Count()-1;k>=0;k--)
354 operator[](w+k)=v[k];
369 while(w<count && v[k]==v[w]) w++;
383 int k=0,w=0,s=Count();
385 while(w<s &&
operator[](w)<v[k]) w++;
386 if(w>=s ||
operator[](w)>v[k])
399 while(w<Count() &&
operator[](w)<v[k]) w++;
400 if(w>=Count())
break;
401 if(
operator[](w)==v[k++])
402 operator[](z++)=operator[](w++);
414 while(w<Count() &&
operator[](w)<v[k])
416 if(z!=w) operator[](z++)=operator[](w++);
418 if(w>=Count())
break;
424 if(z!=w) operator[](z++)=operator[](w++);
436 if(count==v.
Count()) {
438 for(k=0;k<count && operator[](k)==v[k];k++);
447 if(count<=v.
Count()) {
449 for(k=0,k2=0;k<count && k2<v.
Count();k++)
450 while(k2<v.
Count() &&
operator[](k)!=v[k2]) k2++;
461 if(index<0) index=Count();
462 if((w=v.
Count()) > 0) {
467 for(k=z-1;k>=index;k--)
468 operator[](k+w)=operator[](k);
470 for(k=index;k<index+w;k++)
471 operator[](k)=v.operator[](k-index);
480 if(index<0) index=Count();
487 for(k=z-1;k>=index;k--)
488 operator[](k+1)=operator[](k);
497 for(
int k=count/2-1;k>=0;k--)
505 result=abs(Count()-v.
Count());
506 for(
int i=(Count()<v.
Count()?Count():v.
Count())-1;i>=0;i--)
507 if(!((*
this)[i]==v[i]))
510 for(
int i=(Count()<v.
Count()?Count():v.
Count())-1;i>=0;i--)
511 result+=abs((*
this)[i]-v[i]);
514 for(
int i=0;i<Count()-1;i++) {
515 int j=v.
Find((*
this)[i]);
516 if(j>=0 && j<v.
Count()-1 && (*this)[i+1]==v[j+1])
529 int n1=Count()+1,n2=v.
Count()+1;
534 for(
int i=1;i<n1;i++)
537 for(
int j=1;j<n2;j++)
539 for(
int i=1;i<n1;i++)
540 for(
int j=1;j<n2;j++) {
543 m[i+n1*j]=m[i-1+n1*(j-1)];
544 if(!((*
this)[i-1]==v[j-1]))
547 if(m[i+n1*j]>m[i-1+n1*j]+1)
548 m[i+n1*j]=m[i-1+n1*j]+1;
550 if(m[i+n1*j]>m[i+n1*(j-1)]+1)
551 m[i+n1*j]=m[i+n1*(j-1)]+1;
553 result=m[Count()+n1*v.
Count()];