-
Notifications
You must be signed in to change notification settings - Fork 7
/
Individuals.cpp
61 lines (48 loc) · 1.12 KB
/
Individuals.cpp
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
// Individuals.cpp: A collection of individuals
#include "Individuals.h"
#include <iostream>
using namespace std;
// Individuals(): default constructor
Individuals::Individuals()
{}
Individuals::~Individuals()
{
for(begin();more();next())
delete pedigree[ iter ];
}
void Individuals::initialize()
{
for ( iter = 0 ; iter < pedigree.size() ; iter++ ) pedigree[ iter ]->reserveMemory();
}
void Individuals::freeMatches()
{
for(begin();more();next()) pedigree[ iter ]->freeMatches();
}
void Individuals::freeMarkers()
{
for(begin();more();next()) { pedigree[ iter ]->clearMarkers(); }
}
void Individuals::print( ostream& out )
{
for(begin();more();next())
out << pedigree[ iter ]->getID() << endl;
}
void Individuals::begin()
{
iter = 0;
}
bool Individuals::more()
{
return iter < pedigree.size();
}
Individual * Individuals::next()
{
return pedigree[ iter++ ];
}
// addIndividual(): adds an Individual object
void Individuals::addIndividual(Individual * ind)
{
pedigree.push_back(ind);
ind->setNumericID( (unsigned int) num_samples++ );
}
// end Individuals.cpp