1 : |
agomez |
1 |
#ifndef popinfomatrix_h
|
2 : |
|
|
#define popinfomatrix_h
|
3 : |
|
|
|
4 : |
|
|
#include "intvector.h" |
5 : |
|
|
#include "popinfovector.h" |
6 : |
|
|
|
7 : |
|
|
/**
|
8 : |
|
|
* \class PopInfoMatrix
|
9 : |
|
|
* \brief This class implements a dynamic vector of PopInfoVector values
|
10 : |
|
|
*/
|
11 : |
|
|
class PopInfoMatrix {
|
12 : |
|
|
public:
|
13 : |
|
|
/**
|
14 : |
|
|
* \brief This is the default PopInfoMatrix constructor
|
15 : |
|
|
*/
|
16 : |
|
|
PopInfoMatrix() { nrow = 0; v = 0; };
|
17 : |
|
|
/**
|
18 : |
|
|
* \brief This is the PopInfoMatrix constructor for a specified size
|
19 : |
|
|
* \param nr is the size of the vector to be created
|
20 : |
|
|
* \param nc is the length of each row to be created (ie. the size of the PopInfoVector to be created for each row)
|
21 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
22 : |
|
|
*/
|
23 : |
|
|
PopInfoMatrix(int nr, int nc, PopInfo initial);
|
24 : |
|
|
/**
|
25 : |
|
|
* \brief This is the PopInfoMatrix constructor that creates a copy of an existing PopInfoMatrix
|
26 : |
|
|
* \param initial is the PopInfoMatrix to copy
|
27 : |
|
|
*/
|
28 : |
|
|
PopInfoMatrix(const PopInfoMatrix& initial);
|
29 : |
|
|
/**
|
30 : |
|
|
* \brief This is the PopInfoMatrix destructor
|
31 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
32 : |
|
|
*/
|
33 : |
|
|
~PopInfoMatrix();
|
34 : |
|
|
/**
|
35 : |
|
|
* \brief This will return the number of columns in row i of the vector
|
36 : |
|
|
* \param i is the row of the vector to have the number of columns counted
|
37 : |
|
|
* \return the number of columns in row i of the vector
|
38 : |
|
|
* \note This is the number of entries in the PopInfoVector that is entry i of the PopInfoMatrix
|
39 : |
|
|
*/
|
40 : |
|
|
int Ncol(int i = 0) const { return v[i]->Size(); };
|
41 : |
|
|
/**
|
42 : |
|
|
* \brief This will return the number of rows of the vector
|
43 : |
|
|
* \return the number of rows of the vector
|
44 : |
|
|
*/
|
45 : |
|
|
int Nrow() const { return nrow; };
|
46 : |
|
|
/**
|
47 : |
|
|
* \brief This will return the value of an element of the vector
|
48 : |
|
|
* \param pos is the element of the vector to be returned
|
49 : |
|
|
* \return the value of the specified element
|
50 : |
|
|
*/
|
51 : |
|
|
PopInfoVector& operator [] (int pos) { return *v[pos]; };
|
52 : |
|
|
/**
|
53 : |
|
|
* \brief This will return the value of an element of the vector
|
54 : |
|
|
* \param pos is the element of the vector to be returned
|
55 : |
|
|
* \return the value of the specified element
|
56 : |
|
|
*/
|
57 : |
|
|
const PopInfoVector& operator [] (int pos) const { return *v[pos]; };
|
58 : |
|
|
/**
|
59 : |
|
|
* \brief This will add new entries to the vector
|
60 : |
|
|
* \param add is the number of new entries to the vector
|
61 : |
|
|
* \param length is the number of entries to the PopInfoVector that is created
|
62 : |
|
|
* \param value is the value that will be entered for the new entries
|
63 : |
|
|
*/
|
64 : |
|
|
void AddRows(int add, int length, PopInfo value);
|
65 : |
|
|
/**
|
66 : |
|
|
* \brief This will delete an entry from the vector
|
67 : |
|
|
* \param pos is the element of the vector to be deleted
|
68 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
69 : |
|
|
*/
|
70 : |
|
|
void Delete(int pos);
|
71 : |
|
|
protected:
|
72 : |
|
|
/**
|
73 : |
|
|
* \brief This is number of rows of the vector
|
74 : |
|
|
*/
|
75 : |
|
|
int nrow;
|
76 : |
|
|
/**
|
77 : |
|
|
* \brief This is the vector of PopInfoVector values
|
78 : |
|
|
*/
|
79 : |
|
|
PopInfoVector** v;
|
80 : |
|
|
};
|
81 : |
|
|
|
82 : |
|
|
#endif
|