1 : |
agomez |
1 |
#ifndef popinfovector_h
|
2 : |
|
|
#define popinfovector_h
|
3 : |
|
|
|
4 : |
|
|
#include "conversionindex.h" |
5 : |
|
|
#include "popinfo.h" |
6 : |
|
|
|
7 : |
|
|
/**
|
8 : |
|
|
* \class PopInfoVector
|
9 : |
|
|
* \brief This class implements a dynamic vector of PopInfo values
|
10 : |
|
|
*/
|
11 : |
|
|
class PopInfoVector {
|
12 : |
|
|
public:
|
13 : |
|
|
/**
|
14 : |
|
|
* \brief This is the default PopInfoVector constructor
|
15 : |
|
|
*/
|
16 : |
|
|
PopInfoVector() { size = 0; v = 0; };
|
17 : |
|
|
/**
|
18 : |
|
|
* \brief This is the PopInfoVector constructor for a specified size
|
19 : |
|
|
* \param sz is the size of the vector to be created
|
20 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
21 : |
|
|
*/
|
22 : |
|
|
PopInfoVector(int sz, PopInfo initial);
|
23 : |
|
|
/**
|
24 : |
|
|
* \brief This is the PopInfoVector constructor that creates a copy of an existing PopInfoVector
|
25 : |
|
|
* \param initial is the PopInfoVector to copy
|
26 : |
|
|
*/
|
27 : |
|
|
PopInfoVector(const PopInfoVector& initial);
|
28 : |
|
|
/**
|
29 : |
|
|
* \brief This is the PopInfoVector destructor
|
30 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
31 : |
|
|
*/
|
32 : |
|
|
~PopInfoVector();
|
33 : |
|
|
/**
|
34 : |
|
|
* \brief This will add new blank (ie. NULL) entries to the vector
|
35 : |
|
|
* \param addsize is the number of blank entries that will be entered
|
36 : |
|
|
*/
|
37 : |
|
|
void resizeBlank(int addsize);
|
38 : |
|
|
/**
|
39 : |
|
|
* \brief This will add one new entry to the vector
|
40 : |
|
|
* \param value is the value that will be entered for the new entry
|
41 : |
|
|
*/
|
42 : |
|
|
void resize(PopInfo value);
|
43 : |
|
|
/**
|
44 : |
|
|
* \brief This will delete an entry from the vector
|
45 : |
|
|
* \param pos is the element of the vector to be deleted
|
46 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
47 : |
|
|
*/
|
48 : |
|
|
void Delete(int pos);
|
49 : |
|
|
/**
|
50 : |
|
|
* \brief This will return the size of the vector
|
51 : |
|
|
* \return the size of the vector
|
52 : |
|
|
*/
|
53 : |
|
|
int Size() const { return size; };
|
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 : |
|
|
PopInfo& operator [] (int pos) { return v[pos]; };
|
60 : |
|
|
/**
|
61 : |
|
|
* \brief This will return the value of an element of the vector
|
62 : |
|
|
* \param pos is the element of the vector to be returned
|
63 : |
|
|
* \return the value of the specified element
|
64 : |
|
|
*/
|
65 : |
|
|
const PopInfo& operator [] (int pos) const { return v[pos]; };
|
66 : |
|
|
/**
|
67 : |
|
|
* \brief This function will sum the elements of an existing PopInfoVector, possibly allowing for the length grouping to be changed using a ConversionIndex
|
68 : |
|
|
* \param Number is the PopInfoVector containing the elements to be summed
|
69 : |
|
|
* \param CI is the ConversionIndex to be used to convert from one length grouping to another
|
70 : |
|
|
*/
|
71 : |
|
|
void Sum(const PopInfoVector* const Number, const ConversionIndex& CI);
|
72 : |
|
|
protected:
|
73 : |
|
|
/**
|
74 : |
|
|
* \brief This is the vector of PopInfo values
|
75 : |
|
|
*/
|
76 : |
|
|
PopInfo* v;
|
77 : |
|
|
/**
|
78 : |
|
|
* \brief This is the size of the vector
|
79 : |
|
|
*/
|
80 : |
|
|
int size;
|
81 : |
|
|
};
|
82 : |
|
|
|
83 : |
|
|
#endif
|