1 : |
agomez |
1 |
#ifndef popratioindexvector_h
|
2 : |
|
|
#define popratioindexvector_h
|
3 : |
|
|
|
4 : |
|
|
#include "popratiovector.h" |
5 : |
|
|
|
6 : |
|
|
/**
|
7 : |
|
|
* \class PopRatioIndexVector
|
8 : |
|
|
* \brief This class implements a dynamic vector of PopRatioVector values, indexed from minpos not 0
|
9 : |
|
|
*/
|
10 : |
|
|
class PopRatioIndexVector {
|
11 : |
|
|
public:
|
12 : |
|
|
/**
|
13 : |
|
|
* \brief This is the default PopRatioIndexVector constructor
|
14 : |
|
|
*/
|
15 : |
|
|
PopRatioIndexVector() { minpos = 0; size = 0; v = 0; };
|
16 : |
|
|
/**
|
17 : |
|
|
* \brief This is the PopRatioIndexVector constructor for a specified size
|
18 : |
|
|
* \param sz is the size of the vector to be created
|
19 : |
|
|
* \param minpos is the index for the vector to be created
|
20 : |
|
|
* \note The elements of the vector will all be created, and set to zero
|
21 : |
|
|
*/
|
22 : |
|
|
PopRatioIndexVector(int sz, int minpos);
|
23 : |
|
|
/**
|
24 : |
|
|
* \brief This is the PopRatioIndexVector constructor for a specified size with an initial value
|
25 : |
|
|
* \param sz is the size of the vector to be created
|
26 : |
|
|
* \param minpos is the index for the vector to be created
|
27 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
28 : |
|
|
*/
|
29 : |
|
|
PopRatioIndexVector(int sz, int minpos, const PopRatioVector& initial);
|
30 : |
|
|
/**
|
31 : |
|
|
* \brief This is the PopRatioIndexVector constructor that creates a copy of an existing PopRatioIndexVector
|
32 : |
|
|
* \param initial is the PopRatioIndexVector to copy
|
33 : |
|
|
*/
|
34 : |
|
|
PopRatioIndexVector(const PopRatioIndexVector& initial);
|
35 : |
|
|
/**
|
36 : |
|
|
* \brief This is the PopRatioIndexVector destructor
|
37 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
38 : |
|
|
*/
|
39 : |
|
|
~PopRatioIndexVector();
|
40 : |
|
|
/**
|
41 : |
|
|
* \brief This will add new entries to the vector
|
42 : |
|
|
* \param addsize is the number of new entries to the vector
|
43 : |
|
|
* \param newminpos is the index for the vector to be created
|
44 : |
|
|
* \param initial is the value that will be entered for the new entries
|
45 : |
|
|
*/
|
46 : |
|
|
void resize(int addsize, int newminpos, const PopRatioVector& initial);
|
47 : |
|
|
/**
|
48 : |
|
|
* \brief This will return the value of an element of the vector
|
49 : |
|
|
* \param pos is the element of the vector to be returned
|
50 : |
|
|
* \return the value of the specified element
|
51 : |
|
|
*/
|
52 : |
|
|
PopRatioVector& operator [] (int pos) { return *v[pos - minpos]; };
|
53 : |
|
|
/**
|
54 : |
|
|
* \brief This will return the value of an element of the vector
|
55 : |
|
|
* \param pos is the element of the vector to be returned
|
56 : |
|
|
* \return the value of the specified element
|
57 : |
|
|
*/
|
58 : |
|
|
const PopRatioVector& operator [] (int pos) const { return *v[pos - minpos]; };
|
59 : |
|
|
/**
|
60 : |
|
|
* \brief This will return the index of the vector
|
61 : |
|
|
* \return the index of the vector
|
62 : |
|
|
*/
|
63 : |
|
|
int minCol() const { return minpos; };
|
64 : |
|
|
/**
|
65 : |
|
|
* \brief This will return the length of the vector
|
66 : |
|
|
* \return the length of the vector
|
67 : |
|
|
*/
|
68 : |
|
|
int maxCol() const { return minpos + size; };
|
69 : |
|
|
/**
|
70 : |
|
|
* \brief This will return the size of the vector
|
71 : |
|
|
* \return the size of the vector
|
72 : |
|
|
*/
|
73 : |
|
|
int Size() const { return size; };
|
74 : |
|
|
protected:
|
75 : |
|
|
/**
|
76 : |
|
|
* \brief This is the index for the vector
|
77 : |
|
|
*/
|
78 : |
|
|
int minpos;
|
79 : |
|
|
/**
|
80 : |
|
|
* \brief This is the size of the vector
|
81 : |
|
|
*/
|
82 : |
|
|
int size;
|
83 : |
|
|
/**
|
84 : |
|
|
* \brief This is the indexed vector of PopRatioVector values
|
85 : |
|
|
*/
|
86 : |
|
|
PopRatioVector** v;
|
87 : |
|
|
};
|
88 : |
|
|
|
89 : |
|
|
#endif
|