1 : |
agomez |
1 |
#ifndef popratiovector_h
|
2 : |
|
|
#define popratiovector_h
|
3 : |
|
|
|
4 : |
|
|
#include "popratio.h" |
5 : |
|
|
|
6 : |
|
|
/**
|
7 : |
|
|
* \class PopRatioVector
|
8 : |
|
|
* \brief This class implements a dynamic vector of PopRatio values
|
9 : |
|
|
*/
|
10 : |
|
|
class PopRatioVector {
|
11 : |
|
|
public:
|
12 : |
|
|
/**
|
13 : |
|
|
* \brief This is the default PopRatioVector constructor
|
14 : |
|
|
*/
|
15 : |
|
|
PopRatioVector() { size = 0; v = 0;};
|
16 : |
|
|
/**
|
17 : |
|
|
* \brief This is the PopRatioVector constructor for a specified size with an initial value
|
18 : |
|
|
* \param sz is the size of the vector to be created
|
19 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
20 : |
|
|
*/
|
21 : |
|
|
PopRatioVector(int sz, PopRatio initial);
|
22 : |
|
|
/**
|
23 : |
|
|
* \brief This is the PopRatioVector constructor that creates a copy of an existing PopRatioVector
|
24 : |
|
|
* \param initial is the PopRatioVector to copy
|
25 : |
|
|
*/
|
26 : |
|
|
PopRatioVector(const PopRatioVector& initial);
|
27 : |
|
|
/**
|
28 : |
|
|
* \brief This is the PopRatioVector destructor
|
29 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
30 : |
|
|
*/
|
31 : |
|
|
~PopRatioVector();
|
32 : |
|
|
/**
|
33 : |
|
|
* \brief This will add one new entry to the vector
|
34 : |
|
|
* \param value is the value that will be entered for the new entry
|
35 : |
|
|
*/
|
36 : |
|
|
void resize(PopRatio value);
|
37 : |
|
|
/**
|
38 : |
|
|
* \brief This will add one new entry to the vector
|
39 : |
|
|
* \param num is the value of N for the new PopRatio entry
|
40 : |
|
|
* \param rat is the value of R for the new PopRatio entry
|
41 : |
|
|
*/
|
42 : |
|
|
void resize(double* num, double rat);
|
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 : |
|
|
PopRatio& 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 PopRatio& operator [] (int pos) const { return v[pos]; };
|
66 : |
|
|
protected:
|
67 : |
|
|
/**
|
68 : |
|
|
* \brief This is the vector of PopRatio values
|
69 : |
|
|
*/
|
70 : |
|
|
PopRatio* v;
|
71 : |
|
|
/**
|
72 : |
|
|
* \brief This is the size of the vector
|
73 : |
|
|
*/
|
74 : |
|
|
int size;
|
75 : |
|
|
};
|
76 : |
|
|
|
77 : |
|
|
#endif
|