-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDeadTree.cpp
More file actions
77 lines (69 loc) · 2.44 KB
/
DeadTree.cpp
File metadata and controls
77 lines (69 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//---------------------------------------------------------------------------
#include <stdio.h>
#include "DeadTree.h"
#include "TreePopulation.h"
//---------------------------------------------------------------------------
using namespace std;
////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////*/
clDeadTree::clDeadTree(int iType, int iSpecies, int iNumFloats, int iNumInts,
int iNumStrings, int iNumBools) {
int i;
m_iSpecies = iSpecies;
m_iType = iType;
mp_oNext = NULL;
//Null out the pointers
mp_fFloatValues = NULL;
mp_iIntValues = NULL;
mp_sStringValues = NULL;
mp_bBoolValues = NULL;
if (iNumFloats > 0) {
mp_fFloatValues = new float[iNumFloats];
for (i = 0; i < iNumFloats; i++)
mp_fFloatValues[i] = 0;
}
if (iNumInts > 0) {
mp_iIntValues = new int[iNumInts];
for (i = 0; i < iNumInts; i++)
mp_iIntValues[i] = 0;
}
if (iNumStrings > 0) {
mp_sStringValues = new string[iNumStrings];
}
if (iNumBools > 0) {
mp_bBoolValues = new bool[iNumBools];
for (i = 0; i < iNumBools; i++)
mp_bBoolValues[i] = false;
}
m_iDeadCode = notdead;
}
////////////////////////////////////////////////////////////////////////////
// Destructor
////////////////////////////////////////////////////////////////////////////
clDeadTree::~clDeadTree() {
//Delete all arrays
delete[] mp_fFloatValues;
delete[] mp_iIntValues;
delete[] mp_sStringValues;
delete[] mp_bBoolValues;
}
////////////////////////////////////////////////////////////////////////////
// GetValue
///////////////////////////////////////////////////////////////////////////*/
void clDeadTree::GetValue(short int iCode, int *p_iValHolder) {
*p_iValHolder = mp_iIntValues[iCode];
}
//---------------------------------------------------------------------------
void clDeadTree::GetValue(short int iCode, float *p_fValHolder) {
*p_fValHolder = mp_fFloatValues[iCode];
}
//---------------------------------------------------------------------------
void clDeadTree::GetValue(short int iCode, bool *p_bValHolder) {
*p_bValHolder = mp_bBoolValues[iCode];
}
//---------------------------------------------------------------------------
void clDeadTree::GetValue(short int iCode, string *p_sValHolder) {
*p_sValHolder = mp_sStringValues[iCode];
}
//---------------------------------------------------------------------------