TProcuraAdversa
Algoritmos de procura adversa
Loading...
Searching...
No Matches
TVector.h
Go to the documentation of this file.
1// TVector.h: interface for the TVector class.
2//
4
5#if !defined(AFX_TVECTOR_H__7E674C3E_074D_4F78_8839_D28D9BAD66FD__INCLUDED_)
6#define AFX_TVECTOR_H__7E674C3E_074D_4F78_8839_D28D9BAD66FD__INCLUDED_
7
8#if _MSC_VER > 1000
9#pragma once
10#endif // _MSC_VER > 1000
11
12#include <stdlib.h>
13#include "TRand.h"
14
15
17// TVector class
19// Author: Jose Coelho
20// Last revision: 2007-04-17
21// Description: template vector class, to avoid the need to alloc/dealloc arrays
23
24
25template <class Item>
27{
28private:
29 TVector<int> *idx;
30 Item *v;
31 int sz,count;
32 void Size(int size);
33 // sort methods in vector
34 void QuickSort(int start,int end);
35 void Insertion(int start, int end);
36 void Exch(int i, int j) { Item a=v[i]; v[i]=v[j]; v[j]=a; }
37 // sort methods in index vector
38 void QuickSortIdx(int start,int end);
39 void ExchIdx(int i, int j) { int a=(*idx)[i]; (*idx)[i]=(*idx)[j]; (*idx)[j]=a; }
40public:
41
42
43
44 // ****************** alteração JM **************//
45 static Item erro;
46 // **********************************************//
47
48 // constructors
49 TVector(int size = 0) { v = NULL; idx = NULL; count = sz = 0; if (size > 0) Size(size); }
50 TVector(int size,Item const *init);
51 virtual ~TVector();
52
53 // access methods
54 inline void Add(Item a) { operator[](count)=a; } // O(1) - add an item in the end of the vector
55 void Insert(Item a,int index=0); // O(N) - insert an element a at index
56 TVector<Item>& Insert(TVector<Item>&v,int index=0); // O(N) - insert elements of v starting at index
57
58 // 2007/04/17: push is the same as Add method
59 inline void Push(Item a) { Add(a); }
60 // 2007/04/17: pop is the same as Last(), but the element returned is removed from the vector
61 inline Item& Pop() { if(count>0) return v[--count]; else { return TVector<Item>::erro; } }
62
63 Item& operator[](int i) { // O(1) - acess operator
64 if(i>=sz) Size(2*(i+1)); // duplicate the size used each time that need increase
65 if(i>=count) count=i+1;
66 return v[i];
67 }
68 inline Item& First() { if(count>0) return v[0]; else { return TVector<Item>::erro; } } // O(1) - first element of the vector (2007/04/17: added extra check)
69 inline Item& Last() { if(count>0) return v[count-1]; else { return TVector<Item>::erro; } } // O(1) - last element of the vector (2007/04/17: added extra check)
70 int Count() { return count; } // O(1) - return the number of elements in the vector
71 void Count(int value) { // O(N) - set the vector to a fixed size (the elements are not initializated)
72 if(value>=sz) Size(value);
73 count=value;
74 }
75 // 2007/04/17: return an element at random
76 Item& Random() { if(count>0) return operator[](TRand::rand()%count); else { return TVector<Item>::erro; } }
77
78 // vector methods
79 TVector<Item>& operator=(TVector<Item>&v); // O(N) - reset this vector to vector v
80 TVector<Item>& operator+=(TVector<Item>&v); // O(N) - add vector v to this vector
81
82 // set methods
83 TVector<Item>& BeASet(); // remove duplicates and sort
84 TVector<Item>& Union(TVector<Item>&v); // join elements of two sets
85 TVector<Item>& Intersection(TVector<Item>&v); // intersects elements of two sets
86 TVector<Item>& Difference(TVector<Item>&v); // subtract the elements of v (bug fixed in 2007/03/26)
87 bool Equal(TVector<Item>&v); // return true if v is equal (assume sorted elements)
88 bool Contained(TVector<Item>&v); // return true if it is contained in v or equal (assume sorted elements)
89
90 // operations methods
91 void Delete(int i); // O(N) - delete item i
92 void Remove(Item const &i); // O(N) - remove all itens i
93 int Find(Item &i,bool binary=false,int left=0,int right=-1); // return -1 if item not found (note: use binary sort only if itens are sorted)
94 void Replace(Item const &iold,Item const &inew); // O(N) - replace iold by inew
95 void Sort(TVector<int>*idxvect=NULL); // O(N.log(N)) - sort idx and not the vector (bug fixed in 2006/06/04)
96 void Sort(int start,int end=-1); // sort only from start to end
97 void RandomOrder(); // O(N) - put the actual vector in an random order
98 void Invert(); // O(N) - invert the current element order
99 void Reset(Item const &i); // O(N) - reset all itens to i
100 int Distance(TVector<Item>&v,int type=0); // distance types: 0 - exact match - O(N); 1 - deviation distance - O(N); 2 - R-type distance - O(N^2); 3 - edit distance - O(N^2)
101};
102// O(N)
103
104// **** JM 29/03/2018 *******
105template <class Item>
107// **************************
108
109template <class Item>
110void TVector<Item>::Size(int size)
111{
112 Item *aux=new Item[size];
113 if(v!=NULL) {
114 for(int k=0;k<count;k++)
115 aux[k]=v[k];
116 delete [] v;
117 }
118 v=aux;
119 sz=size;
120}
121
122template <class Item>
123TVector<Item>::TVector(int size,Item const *init)
124{
125 int k;
126 v=NULL;
127 count=sz=0;
128 if(size>0) {
129 Size(size);
130 for(k=0;k<size;k++)
131 operator[](k)=init[k];
132 }
133}
134
135template <class Item>
137 if(v!=NULL) delete [] v;
138}
139
140
142// Searching
144
145template <class Item>
146int TVector<Item>::Find(Item &i,bool binary, int left, int right)
147{
148 if(binary) {
149 if(right<0 || right>count-1) right=count-1;
150 if(left<0 || left>right) left=0;
151 int mid;
152
153 while(left<=right) {
154 mid=(left+right)>>1;
155 if(v[mid]==i) return mid;
156 if(v[mid]<i) left=mid+1;
157 else right=mid-1;
158 }
159 } else {
160 for(int k=0;k<count;k++)
161 if(v[k]==i)
162 return k;
163 }
164 return -1;
165}
166
168// Sorting
170
171template <class Item>
172void TVector<Item>::Sort(TVector<int>*idxvect) // quicksort & insertion
173{
174 if(idxvect==NULL) { // just sort this vector
175 QuickSort(0,count-1); // make numbers more or less sorted
176 Insertion(0,count-1); // finish sort
177 // for integer numbers it takes about 1.5 seconds for 10^6 random numbers
178 // performance ok for already sorted sequences
179 } else { // sort the index
180 idx=idxvect;
181 idx->Count(count);
182 for(int k=0;k<count;k++)
183 (*idx)[k]=k;
184 QuickSortIdx(0,count-1);
185 }
186}
187
188template <class Item>
189void TVector<Item>::Sort(int start,int end) // sort only from start to end
190{
191 if(end>count-1 || end<0) end=count-1;
192 if(start<0) start=0;
193 if(start<end) {
194 QuickSort(start,end); // make numbers more or less sorted
195 Insertion(start,end); // finish sort
196 }
197}
198
199
200template <class Item>
201void TVector<Item>::QuickSort(int start,int end) // quicksort
202{
203 if(end-start>32) { // otherwise left work to insertion sort
204 Exch((start+end)>>1,end-1); // the middle element next to the end
205 // sort the three elements
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);
209
210 // v[start] will be for sure less or equal than v[end-1]
211 // v[end] will be for sure greater or equal than v[end-1]
212 start++; end--;
213
214 // partition
215 int i=start-1,j=end;
216 Item a=v[end];
217 for(;;) {
218 while(v[++i]<a);
219 while(a<v[--j] && j>start);
220 if(i>=j) break;
221 Exch(i,j);
222 }
223 Exch(i,end);
224
225 QuickSort(start-1,i-1);
226 QuickSort(i+1,end+1);
227 } //else Insertion(start,end);
228}
229
230template <class Item>
231void TVector<Item>::Insertion(int start,int end) // insertion sort
232{
233 int i;
234 for(i=end; i>start; i--)
235 if(v[i-1]>v[i])
236 Exch(i-1,i);
237
238 for(i=start+2; i<=end; i++) {
239 int j=i;
240 Item a=v[i];
241 while(a<v[j-1]) {
242 v[j]=v[j-1];
243 j--;
244 }
245 v[j]=a;
246 }
247}
248
249template <class Item>
250void TVector<Item>::QuickSortIdx(int start,int end) // quicksort
251{
252 if(end-start<3) { // few elements
253 if(end-start==1) { // two elements
254 if(v[(*idx)[end]]<v[(*idx)[start]]) ExchIdx(end,start);
255 } else if(end-start==2) { // three elements
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);
259 }
260 } else { // otherwise is sorted
261 ExchIdx((start+end)>>1,end-1); // the middle element next to the end
262 // sort the three elements
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);
266
267 // v[start] will be for sure less or equal than v[end-1]
268 // v[end] will be for sure greater or equal than v[end-1]
269 start++; end--;
270
271 // partition
272 int i=start-1,j=end;
273 Item a=v[(*idx)[end]];
274 for(;;) {
275 while(v[(*idx)[++i]]<a);
276 while(a<v[(*idx)[--j]] && j>start);
277 if(i>=j) break;
278 ExchIdx(i,j);
279 }
280 ExchIdx(i,end);
281
282 if(i>start) QuickSortIdx(start-1,i-1);
283 if(i<end) QuickSortIdx(i+1,end+1);
284 }
285}
286
287// O(N)
288template <class Item>
289void TVector<Item>::RandomOrder() // put the vector in an random order
290{
291 for(int k=count-1;k>0;k--) // select a random possition to k
292 Exch(k,TRand::rand()%(k+1));
293}
294
295// O(N)
296template <class Item>
297void TVector<Item>::Remove(Item const &i)
298{
299 int k,w;
300 for(w=0,k=0;w<count;w++) { // O(N)
301 if(k!=w) v[k]=v[w];
302 if(v[w]!=i) k++;
303 }
304 count=k;
305}
306
307// O(N)
308template <class Item>
309void TVector<Item>::Reset(Item const &i)
310{
311 for(int j=0;j<count;j++)
312 v[j]=i;
313}
314
315// O(N)
316template <class Item>
317void TVector<Item>::Replace(Item const &iold,Item const &inew)
318{
319 for(int k=0;k<count;k++)
320 if(v[k]==iold) // O(N)
321 v[k]=inew;
322}
323
324// O(N)
325template <class Item>
327{
328 int k;
329 for(k=i;k<count-1;k++) { // O(N)
330 v[k]=v[k+1];
331 }
332 count--;
333}
334
335// O(N)
336template <class Item>
338{
339 int k;
340 Count(v.Count());
341 for(k=v.Count()-1;k>=0;k--)
342 operator[](k)=v[k];
343 return *this;
344}
345
346// O(N)
347template <class Item>
349{
350 int k,w;
351 w=Count();
352 Count(w+v.Count());
353 for(k=v.Count()-1;k>=0;k--)
354 operator[](w+k)=v[k];
355 return *this;
356}
357
358// set methods
359template <class Item>
360TVector<Item>& TVector<Item>::BeASet() { // remove duplicates and sort
361
362 if(count>0) {
363 Sort();
364
365 // remove duplicates
366 int k=0,w=1;
367
368 while(true) {
369 while(w<count && v[k]==v[w]) w++; // move w to the next different position
370 if(w>=count) break;
371 k++;
372 if(k!=w) v[k]=v[w];
373 }
374
375 count=k+1;
376 }
377
378 return *this;
379}
380
381template <class Item>
382TVector<Item>& TVector<Item>::Union(TVector<Item>&v) { // join elements of two sets
383 int k=0,w=0,s=Count();
384 while(k<v.Count()) {
385 while(w<s && operator[](w)<v[k]) w++; // see if v[k] is in the vector
386 if(w>=s || operator[](w)>v[k]) // not there
387 Add(v[k++]); // add v[k]
388 else k++; // already there, next k
389 }
390 Sort();
391
392 return *this;
393}
394
395template <class Item>
396TVector<Item>& TVector<Item>::Intersection(TVector<Item>&v) { // intersects elements of two sets
397 int k=0,w=0,z=0;
398 while(k<v.Count()) {
399 while(w<Count() && operator[](w)<v[k]) w++; // see if v[k] is in the vector
400 if(w>=Count()) break;
401 if(operator[](w)==v[k++]) // keep element, any case go for next k
402 operator[](z++)=operator[](w++);
403 }
404 Count(z);
405
406 return *this;
407}
408
409// bug found in 2007/03/26
410template <class Item>
411TVector<Item>& TVector<Item>::Difference(TVector<Item>&v) { // subtract the elements of v
412 int k=0,w=0,z=0;
413 while(k<v.Count()) { // process all elements of v
414 while(w<Count() && operator[](w)<v[k]) // w - process all elements of this vector
415 // not in v, keep element
416 if(z!=w) operator[](z++)=operator[](w++);
417 else { z++; w++; }
418 if(w>=Count()) break;
419 k++; // next element of v
420 w++; // this w is not inserted, skip
421 }
422 // copy the rest of the elements, not in v
423 while(w<Count())
424 if(z!=w) operator[](z++)=operator[](w++);
425 else { z++; w++; }
426
427 // reset the size of the vector
428 Count(z);
429
430 return *this;
431}
432
433// O(N)
434template <class Item>
435bool TVector<Item>::Equal(TVector<Item>&v) { // return true if v is equal (assume sorted elements)
436 if(count==v.Count()) {
437 int k;
438 for(k=0;k<count && operator[](k)==v[k];k++);
439 return k==count;
440 }
441 return false;
442}
443
444// O(N)
445template <class Item>
446bool TVector<Item>::Contained(TVector<Item>&v) { // return true if it is contained in v or equal (assume sorted elements)
447 if(count<=v.Count()) {
448 int k,k2;
449 for(k=0,k2=0;k<count && k2<v.Count();k++)
450 while(k2<v.Count() && operator[](k)!=v[k2]) k2++;
451 return k==count;
452 }
453 return false;
454}
455
456
457// O(N)
458template <class Item>
459TVector<Item>& TVector<Item>::Insert(TVector<Item>&v,int index) { // insert elements of v starting at index
460 int k,z,w;
461 if(index<0) index=Count();
462 if((w=v.Count()) > 0) {
463 z=Count();
464 Count(Count()+w);
465 if(index>z) index=z;
466 // move all elements after index
467 for(k=z-1;k>=index;k--)
468 operator[](k+w)=operator[](k);
469 // copy elements of vector into this one
470 for(k=index;k<index+w;k++)
471 operator[](k)=v.operator[](k-index);
472 }
473 return *this;
474}
475
476// O(N)
477template <class Item>
478void TVector<Item>::Insert(Item a,int index) { // insert an element a at index
479 int k,z;
480 if(index<0) index=Count();
481
482 z=Count();
483 Count(Count()+1);
484 if(index>z) index=z;
485
486 // move all elements after index
487 for(k=z-1;k>=index;k--)
488 operator[](k+1)=operator[](k);
489 // copy element into this position
490 operator[](index)=a;
491}
492
493// O(N)
494template <class Item>
495void TVector<Item>::Invert() { // invert the current order
496 if(count>1)
497 for(int k=count/2-1;k>=0;k--)
498 Exch(k,count-1-k);
499}
500
501template <class Item>
503 int result=0;
504 if(type==0) { // 0 - exact match - O(N)
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])) // use only the operator ==
508 result++;
509 } else if(type==1) { // 1 - deviation distance - O(N)
510 for(int i=(Count()<v.Count()?Count():v.Count())-1;i>=0;i--)
511 result+=abs((*this)[i]-v[i]);
512 } else if(type==2) { // 2 - R-type distance - O(N^2)
513 result=(Count()>v.Count()?Count():v.Count());
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])
517 result--;
518 }
519 } else if(type==3) { // 3 - edit distance - O(N^2)
520/* Base algorithm:
521 m[i,j] = d(s1[1..i], s2[1..j])
522 m[0,0] = 0
523 m[i,0] = i, i=1..|s1|
524 m[0,j] = j, j=1..|s2|
525 m[i,j] = min(m[i-1,j-1] + if s1[i]=s2[j] then 0 else 1 fi,
526 m[i-1, j] + 1,
527 m[i, j-1] + 1 ), i=1..|s1|, j=1..|s2|
528*/
529 int n1=Count()+1,n2=v.Count()+1;
530 TVector<int> m(n1*n2);
531 // m[0,0] = 0
532 m[0+n1*0]=0;
533 // m[i,0] = i, i=1..|s1|
534 for(int i=1;i<n1;i++)
535 m[i+n1*0]=i;
536 // m[0,j] = j, j=1..|s2|
537 for(int j=1;j<n2;j++)
538 m[0+n1*j]=j;
539 for(int i=1;i<n1;i++)
540 for(int j=1;j<n2;j++) {
541 // min:
542 // m[i-1,j-1] + if s1[i]=s2[j] then 0 else 1 fi,
543 m[i+n1*j]=m[i-1+n1*(j-1)];
544 if(!((*this)[i-1]==v[j-1]))
545 m[i+n1*j]++;
546 // m[i-1, 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;
549 // m[i, j-1] + 1
550 if(m[i+n1*j]>m[i+n1*(j-1)]+1)
551 m[i+n1*j]=m[i+n1*(j-1)]+1;
552 }
553 result=m[Count()+n1*v.Count()];
554 }
555 return result;
556}
557
558/* Test results in 2007/04/09
559
560set seed 2
561set 1 -1
562set 2 1000000
563set information 1
564run
565
566#1# Adding 1000000 random elements to vector A
567(31) elements of char
568(31) elements of __int16
569(31) elements of __int32
570(79) elements of __int64
571(46) elements of float
572(79) elements of double
573#2# A.Sort(); 1000000 random elements
574(93) elements of char
575(157) elements of __int16
576(156) elements of __int32
577(219) elements of __int64
578(250) elements of float
579(265) elements of double
580#3# Acessing/verifing if 1000000 elements of A are sorted
581(0) elements of char
582(16) elements of __int16
583(0) elements of __int32
584(15) elements of __int64
585(0) elements of float
586(16) elements of double
587#4# A.RandomOrder(); 1000000 elements
588(63) elements of char
589(109) elements of __int16
590(125) elements of __int32
591(172) elements of __int64
592(140) elements of float
593(172) elements of double
594#5# A.Invert(); 1000000 elements
595(0) elements of char
596(0) elements of __int16
597(16) elements of __int32
598(16) elements of __int64
599(0) elements of float
600(15) elements of double
601#6# A.BeASet(); 1000000 elements (sort and remove duplicates)
602(94) elements of char
603(156) elements of __int16
604(172) elements of __int32
605(234) elements of __int64
606(266) elements of float
607(266) elements of double
608Size of Sets A:
609char 256;
610 __int16 65536;
611 __int32 999879;
612 __int64 1000000;
613 float 980581;
614 double 999890
615#7# B.operator=(A); assigning vectors
616(0) elements of char
617(0) elements of __int16
618(31) elements of __int32
619(31) elements of __int64
620(16) elements of float
621(15) elements of double
622#8# B.Equal(A); comparing vectors
623(0) elements of char
624(0) elements of __int16
625(16) elements of __int32
626(16) elements of __int64
627(0) elements of float
628(15) elements of double
629#9# A.Remove(0); set half of elements to 0 and then remove them.
630(0) elements of char
631(16) elements of __int16
632(78) elements of __int32
633(109) elements of __int64
634(94) elements of float
635(94) elements of double
636#10# B.Difference(A); difference of sets
637(0) elements of char
638(16) elements of __int16
639(15) elements of __int32
640(16) elements of __int64
641(15) elements of float
642(32) elements of double
643Size of sets:
644char 159+97=256;
645 __int16 39708+25828=65536;
646__int32 606688+393191=999879;
647 __int64 606696+393304=1000000;
648 float 594633+385948=980581;
649 double 606457+393433=999890
650#11# B.Union(A); union of sets
651(0) elements of char
652(15) elements of __int16
653(125) elements of __int32
654(188) elements of __int64
655(187) elements of float
656(203) elements of double
657#12# A.Contained(B); A contained in B
658(0) elements of char
659(0) elements of __int16
660(16) elements of __int32
661(31) elements of __int64
662(32) elements of float
663(15) elements of double
664#13# A.Intersection(B); A intersection with B
665(0) elements of char
666(0) elements of __int16
667(16) elements of __int32
668(31) elements of __int64
669(31) elements of float
670(32) elements of double
671#14# A.operator+=(B); adding vectors
672(0) elements of char
673(0) elements of __int16
674(31) elements of __int32
675(62) elements of __int64
676(32) elements of float
677(62) elements of double
678Size of vectors:
679char 415+256=671;
680 __int16 105244+65536=170780;
681__int32 1606567+999879=2606446;
682 __int64 1606696+1000000=2606696;
683 float 1575214+980581=2555795;
684 double 1606347+999890=2606237
685No errors found.Run end.
686
687
688set seed 2
689set 1 -1
690set 2 10000000
691set information 1
692run
693
694#1# Adding 10000000 random elements to vector A
695(266) elements of char
696(266) elements of __int16
697(359) elements of __int32
698(703) elements of __int64
699(578) elements of float
700(860) elements of double
701#2# A.Sort(); 10000000 random elements
702(984) elements of char
703(1516) elements of __int16
704(2000) elements of __int32
705(2609) elements of __int64
706(2891) elements of float
707(3031) elements of double
708#3# Acessing/verifing if 10000000 elements of A are sorted
709(62) elements of char
710(47) elements of __int16
711(63) elements of __int32
712(62) elements of __int64
713(78) elements of float
714(94) elements of double
715#4# A.RandomOrder(); 10000000 elements
716(1563) elements of char
717(1687) elements of __int16
718(1797) elements of __int32
719(1938) elements of __int64
720(1812) elements of float
721(1922) elements of double
722#5# A.Invert(); 10000000 elements
723(16) elements of char
724(31) elements of __int16
725(62) elements of __int32
726(125) elements of __int64
727(47) elements of float
728(125) elements of double
729#6# A.BeASet(); 10000000 elements (sort and remove duplicates)
730(1000) elements of char
731(1547) elements of __int16
732(2031) elements of __int32
733(2688) elements of __int64
734(3015) elements of float
735(3110) elements of double
736Size of Sets A:
737char 256;
738 __int16 65536;
739 __int32 9988463;
740 __int64 10000000;
741 float 8309118;
742 double 9988537
743#7# B.operator=(A); assigning vectors
744(15) elements of char
745(0) elements of __int16
746(172) elements of __int32
747(266) elements of __int64
748(125) elements of float
749(250) elements of double
750#8# B.Equal(A); comparing vectors
751(0) elements of char
752(0) elements of __int16
753(78) elements of __int32
754(125) elements of __int64
755(63) elements of float
756(109) elements of double
757#9# A.Remove(0); set half of elements to 0 and then remove them.
758(0) elements of char
759(0) elements of __int16
760(984) elements of __int32
761(1032) elements of __int64
762(843) elements of float
763(1032) elements of double
764#10# B.Difference(A); difference of sets
765(0) elements of char
766(15) elements of __int16
767(141) elements of __int32
768(172) elements of __int64
769(156) elements of float
770(203) elements of double
771Size of sets:
772char 153+103=256;
773 __int16 39629+25907=65536;
774__int32 6057416+3931047=9988463;
775 __int64 6064739+3935261=10000000;
776 float 5038930+3270188=8309118;
777 double 6059269+3929268=9988537
778#11# B.Union(A); union of sets
779(0) elements of char
780(0) elements of __int16
781(1391) elements of __int32
782(2078) elements of __int64
783(1672) elements of float
784(2297) elements of double
785#12# A.Contained(B); A contained in B
786(0) elements of char
787(0) elements of __int16
788(156) elements of __int32
789(156) elements of __int64
790(156) elements of float
791(203) elements of double
792#13# A.Intersection(B); A intersection with B
793(0) elements of char
794(0) elements of __int16
795(219) elements of __int32
796(203) elements of __int64
797(219) elements of float
798(266) elements of double
799#14# A.operator+=(B); adding vectors
800(0) elements of char
801(0) elements of __int16
802(125) elements of __int32
803(218) elements of __int64
804(79) elements of float
805(218) elements of double
806Size of vectors:
807char 409+256=665;
808 __int16 105165+65536=170701;
809__int32 16045879+9988463=26034342;
810 __int64 16064739+10000000=26064739;
811 float 13348048+8309118=21657166;
812 double 16047806+9988537=26036343
813No errors found.Run end.
814
815
816
817*/
818#endif // !defined(AFX_TVECTOR_H__7E674C3E_074D_4F78_8839_D28D9BAD66FD__INCLUDED_)
static unsigned int rand(int seq=0)
Definition TRand.cpp:61
Item & First()
Definition TVector.h:68
TVector< Item > & BeASet()
Definition TVector.h:360
static Item erro
Definition TVector.h:45
void Delete(int i)
Definition TVector.h:326
bool Contained(TVector< Item > &v)
Definition TVector.h:446
void Insert(Item a, int index=0)
Definition TVector.h:478
void Add(Item a)
Definition TVector.h:54
TVector< Item > & Difference(TVector< Item > &v)
Definition TVector.h:411
Item & Pop()
Definition TVector.h:61
Item & operator[](int i)
Definition TVector.h:63
int Count()
Definition TVector.h:70
void Replace(Item const &iold, Item const &inew)
Definition TVector.h:317
TVector< Item > & Insert(TVector< Item > &v, int index=0)
Definition TVector.h:459
TVector< Item > & Union(TVector< Item > &v)
Definition TVector.h:382
void RandomOrder()
Definition TVector.h:289
void Reset(Item const &i)
Definition TVector.h:309
Item & Random()
Definition TVector.h:76
bool Equal(TVector< Item > &v)
Definition TVector.h:435
void Remove(Item const &i)
Definition TVector.h:297
int Distance(TVector< Item > &v, int type=0)
Definition TVector.h:502
TVector< Item > & operator+=(TVector< Item > &v)
Definition TVector.h:348
virtual ~TVector()
Definition TVector.h:136
void Invert()
Definition TVector.h:495
Item & Last()
Definition TVector.h:69
void Sort(TVector< int > *idxvect=NULL)
Definition TVector.h:172
void Sort(int start, int end=-1)
Definition TVector.h:189
TVector< Item > & operator=(TVector< Item > &v)
Definition TVector.h:337
void Push(Item a)
Definition TVector.h:59
TVector< Item > & Intersection(TVector< Item > &v)
Definition TVector.h:396
int Find(Item &i, bool binary=false, int left=0, int right=-1)
Definition TVector.h:146
TVector(int size, Item const *init)
Definition TVector.h:123
void Count(int value)
Definition TVector.h:71
TVector(int size=0)
Definition TVector.h:49