Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/popratioindexvector.cc
[mareframe] / trunk / gadget / popratioindexvector.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/popratioindexvector.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "popratioindexvector.h"
2 :     #include "gadget.h"
3 :    
4 :     PopRatioIndexVector::PopRatioIndexVector(int sz, int minp) {
5 :     size = (sz > 0 ? sz : 0);
6 :     minpos = minp;
7 :     int i;
8 :     if (size > 0) {
9 :     v = new PopRatioVector*[size];
10 :     for (i = 0; i < size; i++)
11 :     v[i] = new PopRatioVector();
12 :     } else
13 :     v = 0;
14 :     }
15 :    
16 :     PopRatioIndexVector::PopRatioIndexVector(int sz, int minp, const PopRatioVector& initial) {
17 :     size = (sz > 0 ? sz : 0);
18 :     minpos = minp;
19 :     int i;
20 :     if (size > 0) {
21 :     v = new PopRatioVector*[size];
22 :     for (i = 0; i < size; i++)
23 :     v[i] = new PopRatioVector(initial);
24 :     } else
25 :     v = 0;
26 :     }
27 :    
28 :     PopRatioIndexVector::PopRatioIndexVector(const PopRatioIndexVector& initial) {
29 :     size = initial.size;
30 :     minpos = initial.minpos;
31 :     int i;
32 :     if (size > 0) {
33 :     v = new PopRatioVector*[size];
34 :     for (i = 0; i < size; i++)
35 :     v[i] = initial.v[i];
36 :     } else
37 :     v = 0;
38 :     }
39 :    
40 :     PopRatioIndexVector::~PopRatioIndexVector() {
41 :     int i;
42 :     if (v != 0) {
43 :     for (i = 0; i < size; i++)
44 :     delete v[i];
45 :     delete[] v;
46 :     v = 0;
47 :     }
48 :     }
49 :    
50 :     void PopRatioIndexVector::resize(int addsize, int lower, const PopRatioVector& initial) {
51 :     if (addsize <= 0)
52 :     return;
53 :    
54 :     int i;
55 :     if (v == 0) {
56 :     size = addsize;
57 :     minpos = lower;
58 :     v = new PopRatioVector*[size];
59 :     for (i = 0; i < size; i++)
60 :     v[i] = new PopRatioVector(initial);
61 :    
62 :     } else {
63 :     PopRatioVector** vnew = new PopRatioVector*[size + addsize];
64 :     for (i = 0; i < size; i++)
65 :     vnew[i + minpos - lower] = v[i];
66 :     delete[] v;
67 :     v = vnew;
68 :     for (i = size; i < size + addsize; i++)
69 :     v[i] = new PopRatioVector(initial);
70 :     for (i = 0; i < minpos - lower; i++)
71 :     v[i] = new PopRatioVector(initial);
72 :     size += addsize;
73 :     minpos = lower;
74 :     }
75 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge