-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio.h
76 lines (63 loc) · 1.32 KB
/
io.h
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
#ifndef IO_H
#define IO_H
#include<iostream>
#include<string>
#include<assert.h>
#include"strain.h"
using namespace std;
/*
void SaveState(ostream &out, const vector<CStrain*> &strains){
out<<strains.size()<<" "<<rmax<<endl;
vector<CStrain*>::const_iterator it;
for(it=strains.begin(); it!=strains.end(); it++){
(*it)->print_node(out);
}
}
*/
/*
void ReadState(istream &input, vector<CStrain*> &strains){
strains.clear();
string line;
//read the header of the file
int ntotal_read;
if(getline(input,line)){
stringstream ss(line);
ss>>ntotal_read;
ss>>rmax;
}
//first reading all the lines and
//create backbone of the strain
vector<string> lines;
while(getline(input,line))
{
lines.push_back(line);
CStrain *s=new CStrain(-1,NULL);
strains.push_back(s);
}
//Insert the line string into a stream
for(size_t i=0; i<strains.size(); i++){
stringstream ss(lines.at(i));
//alias for current strain (for conciseness)
CStrain &s=*strains.at(i);
//readin ID, N, etc
ss>> s.ID;
ss>> s.N;
ss>> s.fitness;
if(s.N>0) s.SetAlive();
if(! s.dead){
//read M's
for(size_t i=0; i<=rmax; i++){
ss>>s.M[i];
}
}
size_t nneigh;
ss>>nneigh;
for(size_t i=0; i<nneigh; i++){
int neigh_id;
ss>>neigh_id;
s.add_neighbour(strains.at(neigh_id));
}
}
}
*/
#endif /* IO_H */