1 : |
agomez |
1 |
#ifndef otherfoodptrvector_h
|
2 : |
|
|
#define otherfoodptrvector_h
|
3 : |
|
|
|
4 : |
|
|
#include "otherfood.h" |
5 : |
|
|
|
6 : |
|
|
class OtherFood;
|
7 : |
|
|
|
8 : |
|
|
/**
|
9 : |
|
|
* \class OtherFoodPtrVector
|
10 : |
|
|
* \brief This class implements a dynamic vector of OtherFood values
|
11 : |
|
|
*/
|
12 : |
|
|
class OtherFoodPtrVector {
|
13 : |
|
|
public:
|
14 : |
|
|
/**
|
15 : |
|
|
* \brief This is the default OtherFoodPtrVector constructor
|
16 : |
|
|
*/
|
17 : |
|
|
OtherFoodPtrVector() { size = 0; v = 0; };
|
18 : |
|
|
/**
|
19 : |
|
|
* \brief This is the OtherFoodPtrVector constructor that creates a copy of an existing OtherFoodPtrVector
|
20 : |
|
|
* \param initial is the OtherFoodPtrVector to copy
|
21 : |
|
|
*/
|
22 : |
|
|
OtherFoodPtrVector(const OtherFoodPtrVector& initial);
|
23 : |
|
|
/**
|
24 : |
|
|
* \brief This is the OtherFoodPtrVector destructor
|
25 : |
|
|
* \note This will free all the memory allocated to all the elements of the vector
|
26 : |
|
|
*/
|
27 : |
|
|
~OtherFoodPtrVector();
|
28 : |
|
|
/**
|
29 : |
|
|
* \brief This will add one new entry to the vector
|
30 : |
|
|
* \param value is the value that will be entered for the new entry
|
31 : |
|
|
*/
|
32 : |
|
|
void resize(OtherFood* value);
|
33 : |
|
|
/**
|
34 : |
|
|
* \brief This will delete an entry from the vector
|
35 : |
|
|
* \param pos is the element of the vector to be deleted
|
36 : |
|
|
* \note This will free the memory allocated to the deleted element of the vector
|
37 : |
|
|
*/
|
38 : |
|
|
void Delete(int pos);
|
39 : |
|
|
/**
|
40 : |
|
|
* \brief This will return the size of the vector
|
41 : |
|
|
* \return the size of the vector
|
42 : |
|
|
*/
|
43 : |
|
|
int Size() const { return size; };
|
44 : |
|
|
/**
|
45 : |
|
|
* \brief This will return the value of an element of the vector
|
46 : |
|
|
* \param pos is the element of the vector to be returned
|
47 : |
|
|
* \return the value of the specified element
|
48 : |
|
|
*/
|
49 : |
|
|
OtherFood*& operator [] (int pos) { return v[pos]; };
|
50 : |
|
|
/**
|
51 : |
|
|
* \brief This will return the value of an element of the vector
|
52 : |
|
|
* \param pos is the element of the vector to be returned
|
53 : |
|
|
* \return the value of the specified element
|
54 : |
|
|
*/
|
55 : |
|
|
OtherFood* const& operator [] (int pos) const { return v[pos]; };
|
56 : |
|
|
protected:
|
57 : |
|
|
/**
|
58 : |
|
|
* \brief This is the vector of OtherFood values
|
59 : |
|
|
*/
|
60 : |
|
|
OtherFood** v;
|
61 : |
|
|
/**
|
62 : |
|
|
* \brief This is the size of the vector
|
63 : |
|
|
*/
|
64 : |
|
|
int size;
|
65 : |
|
|
};
|
66 : |
|
|
|
67 : |
|
|
#endif
|