1 : |
agomez |
1 |
#ifndef popinfoindexvector_h
|
2 : |
|
|
#define popinfoindexvector_h
|
3 : |
|
|
|
4 : |
|
|
#include "popinfo.h" |
5 : |
|
|
#include "conversionindex.h" |
6 : |
|
|
|
7 : |
|
|
/**
|
8 : |
|
|
* \class PopInfoIndexVector
|
9 : |
|
|
* \brief This class implements a dynamic vector of PopInfo values, indexed from minpos not 0
|
10 : |
|
|
*/
|
11 : |
|
|
class PopInfoIndexVector {
|
12 : |
|
|
public:
|
13 : |
|
|
/**
|
14 : |
|
|
* \brief This is the default PopInfoIndexVector constructor
|
15 : |
|
|
*/
|
16 : |
|
|
PopInfoIndexVector() { minpos = 0; size = 0; v = 0; };
|
17 : |
|
|
/**
|
18 : |
|
|
* \brief This is the PopInfoIndexVector constructor for a specified size
|
19 : |
|
|
* \param sz is the size of the vector to be created
|
20 : |
|
|
* \param minpos is the index for the vector to be created
|
21 : |
|
|
* \note The elements of the vector will all be created, and set to zero
|
22 : |
|
|
*/
|
23 : |
|
|
PopInfoIndexVector(int sz, int minpos);
|
24 : |
|
|
/**
|
25 : |
|
|
* \brief This is the PopInfoIndexVector constructor for a specified size with an initial value
|
26 : |
|
|
* \param sz is the size of the vector to be created
|
27 : |
|
|
* \param minpos is the index for the vector to be created
|
28 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
29 : |
|
|
*/
|
30 : |
|
|
PopInfoIndexVector(int sz, int minpos, PopInfo initial);
|
31 : |
|
|
/**
|
32 : |
|
|
* \brief This is the PopInfoIndexVector constructor that creates a copy of an existing PopInfoIndexVector
|
33 : |
|
|
* \param initial is the PopInfoIndexVector to copy
|
34 : |
|
|
*/
|
35 : |
|
|
PopInfoIndexVector(const PopInfoIndexVector& initial);
|
36 : |
|
|
/**
|
37 : |
|
|
* \brief This is the PopInfoIndexVector destructor
|
38 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
39 : |
|
|
*/
|
40 : |
|
|
~PopInfoIndexVector();
|
41 : |
|
|
/**
|
42 : |
|
|
* \brief This will add new entries to the vector
|
43 : |
|
|
* \param addsize is the number of new entries to the vector
|
44 : |
|
|
* \param newminpos is the index for the vector to be created
|
45 : |
|
|
* \param value is the value that will be entered for the new entries
|
46 : |
|
|
*/
|
47 : |
|
|
void resize(int addsize, int newminpos, PopInfo value);
|
48 : |
|
|
/**
|
49 : |
|
|
* \brief This will return the value of an element of the vector
|
50 : |
|
|
* \param pos is the element of the vector to be returned
|
51 : |
|
|
* \return the value of the specified element
|
52 : |
|
|
*/
|
53 : |
|
|
PopInfo& operator [] (int pos) { return v[pos - minpos]; };
|
54 : |
|
|
/**
|
55 : |
|
|
* \brief This will return the value of an element of the vector
|
56 : |
|
|
* \param pos is the element of the vector to be returned
|
57 : |
|
|
* \return the value of the specified element
|
58 : |
|
|
*/
|
59 : |
|
|
const PopInfo& operator [] (int pos) const { return v[pos - minpos]; };
|
60 : |
|
|
/**
|
61 : |
|
|
* \brief This will return the index of the vector
|
62 : |
|
|
* \return the index of the vector
|
63 : |
|
|
*/
|
64 : |
|
|
int minCol() const { return minpos; };
|
65 : |
|
|
/**
|
66 : |
|
|
* \brief This will return the length of the vector
|
67 : |
|
|
* \return the length of the vector
|
68 : |
|
|
*/
|
69 : |
|
|
int maxCol() const { return minpos + size; };
|
70 : |
|
|
/**
|
71 : |
|
|
* \brief This will return the size of the vector
|
72 : |
|
|
* \return the size of the vector
|
73 : |
|
|
*/
|
74 : |
|
|
int Size() const { return size; };
|
75 : |
|
|
/**
|
76 : |
|
|
* \brief This function will add a PopInfoIndexVector to the current vector
|
77 : |
|
|
* \param Addition is the PopInfoIndexVector that will be added to the current vector
|
78 : |
|
|
* \param CI is the ConversionIndex that will convert between the length groups of the 2 vectors
|
79 : |
|
|
* \param ratio is a multiplicative constant applied to each entry (default value 1.0)
|
80 : |
|
|
*/
|
81 : |
|
|
void Add(const PopInfoIndexVector& Addition, const ConversionIndex& CI, double ratio = 1.0);
|
82 : |
|
|
/**
|
83 : |
|
|
* \brief This function will add a PopInfoIndexVector to the current vector
|
84 : |
|
|
* \param Addition is the PopInfoIndexVector that will be added to the current vector
|
85 : |
|
|
* \param CI is the ConversionIndex that will convert between the length groups of the 2 vectors
|
86 : |
|
|
* \param Ratio is a DoubleVector of multiplicative constants to be applied to entries individually
|
87 : |
|
|
* \param ratio is a multiplicative constant applied to each entry (default value 1.0)
|
88 : |
|
|
*/
|
89 : |
|
|
void Add(const PopInfoIndexVector& Addition, const ConversionIndex& CI, const DoubleVector& Ratio, double ratio = 1.0);
|
90 : |
|
|
protected:
|
91 : |
|
|
/**
|
92 : |
|
|
* \brief This is the index for the vector
|
93 : |
|
|
*/
|
94 : |
|
|
int minpos;
|
95 : |
|
|
/**
|
96 : |
|
|
* \brief This is the size of the vector
|
97 : |
|
|
*/
|
98 : |
|
|
int size;
|
99 : |
|
|
/**
|
100 : |
|
|
* \brief This is the indexed vector of PopInfo values
|
101 : |
|
|
*/
|
102 : |
|
|
PopInfo* v;
|
103 : |
|
|
};
|
104 : |
|
|
|
105 : |
|
|
#endif
|