1 : |
agomez |
1 |
#ifndef formulavector_h
|
2 : |
|
|
#define formulavector_h
|
3 : |
|
|
|
4 : |
|
|
#include "formula.h" |
5 : |
|
|
|
6 : |
|
|
/**
|
7 : |
|
|
* \class FormulaVector
|
8 : |
|
|
* \brief This class implements a dynamic vector of Formula values
|
9 : |
|
|
*/
|
10 : |
|
|
class FormulaVector {
|
11 : |
|
|
public:
|
12 : |
|
|
/**
|
13 : |
|
|
* \brief This is the default FormulaVector constructor
|
14 : |
|
|
*/
|
15 : |
|
|
FormulaVector() { size = 0; v = 0; };
|
16 : |
|
|
/**
|
17 : |
|
|
* \brief This is the FormulaVector constructor for a specified size
|
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 : |
|
|
FormulaVector(int sz, Formula initial);
|
22 : |
|
|
/**
|
23 : |
|
|
* \brief This is the FormulaVector constructor for a specified size
|
24 : |
|
|
* \param sz is the size of the vector to be created
|
25 : |
|
|
* \param initial is the initial value for all the entries of the vector
|
26 : |
|
|
*/
|
27 : |
|
|
FormulaVector(int sz, double initial);
|
28 : |
|
|
/**
|
29 : |
|
|
* \brief This is the FormulaVector constructor that creates a copy of an existing FormulaVector
|
30 : |
|
|
* \param initial is the FormulaVector to copy
|
31 : |
|
|
*/
|
32 : |
|
|
FormulaVector(const FormulaVector& initial);
|
33 : |
|
|
/**
|
34 : |
|
|
* \brief This is the FormulaVector destructor
|
35 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
36 : |
|
|
*/
|
37 : |
|
|
~FormulaVector();
|
38 : |
|
|
/**
|
39 : |
|
|
* \brief This will add new blank (ie. NULL) entries to the vector
|
40 : |
|
|
* \param addsize is the number of blank entries that will be entered
|
41 : |
|
|
* \param keeper is the Keeper for the current model
|
42 : |
|
|
* \note The new elements of the vector will be created, and set to zero
|
43 : |
|
|
*/
|
44 : |
|
|
void resize(int addsize, Keeper* keeper);
|
45 : |
|
|
/**
|
46 : |
|
|
* \brief This will delete an entry from the vector
|
47 : |
|
|
* \param pos is the element of the vector to be deleted
|
48 : |
|
|
* \param keeper is the Keeper for the current model
|
49 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
50 : |
|
|
*/
|
51 : |
|
|
void Delete(int pos, Keeper* keeper);
|
52 : |
|
|
/**
|
53 : |
|
|
* \brief This will return the size of the vector
|
54 : |
|
|
* \return the size of the vector
|
55 : |
|
|
*/
|
56 : |
|
|
int Size() const { return size; };
|
57 : |
|
|
/**
|
58 : |
|
|
* \brief This will return the value of an element of the vector
|
59 : |
|
|
* \param pos is the element of the vector to be returned
|
60 : |
|
|
* \return the value of the specified element
|
61 : |
|
|
*/
|
62 : |
|
|
Formula& operator [] (int pos) { return v[pos]; };
|
63 : |
|
|
/**
|
64 : |
|
|
* \brief This will return the value of an element of the vector
|
65 : |
|
|
* \param pos is the element of the vector to be returned
|
66 : |
|
|
* \return the value of the specified element
|
67 : |
|
|
*/
|
68 : |
|
|
const Formula& operator [] (int pos) const { return v[pos]; };
|
69 : |
|
|
/**
|
70 : |
|
|
* \brief This function will inform Keeper of the values of the stored Formula
|
71 : |
|
|
* \param keeper is the Keeper for the current model
|
72 : |
|
|
*/
|
73 : |
|
|
void Inform(Keeper* keeper);
|
74 : |
|
|
protected:
|
75 : |
|
|
/**
|
76 : |
|
|
* \brief This is the size of the vector
|
77 : |
|
|
*/
|
78 : |
|
|
int size;
|
79 : |
|
|
/**
|
80 : |
|
|
* \brief This is the vector of Formula values
|
81 : |
|
|
*/
|
82 : |
|
|
Formula* v;
|
83 : |
|
|
};
|
84 : |
|
|
|
85 : |
|
|
#endif
|