-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcgroup.cpp
More file actions
75 lines (61 loc) · 1.38 KB
/
cgroup.cpp
File metadata and controls
75 lines (61 loc) · 1.38 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
#include "cgroup.h"
Cgroup::Cgroup(string n, vector<string> v):groupName(n)
{
for (itSz=v.begin();itSz!=v.end();itSz++)
{
vecAtoms.push_back(new Cgroup::nameId(*itSz));
}
}
Cgroup::~Cgroup()
{
for (itAtoms=vecAtoms.begin();itAtoms!=vecAtoms.end();itAtoms++)
{
delete *itAtoms;
}
}
void Cgroup::print(ofstream &out)
{
if(out.is_open())
{
out<<setw(8)<<left<<"group "<<setw(10)<<getGroupName()<<" type "<<left;
for (itAtoms=vecAtoms.begin();itAtoms!=vecAtoms.end();itAtoms++)
{
for (int i=0; i<(*itAtoms)->getVecSize();i++)
{
out<<" "<<left<<(*itAtoms)->getId(i)<<" ";
}
}
out<<setw(10)<<right<<"# ";
for (itAtoms=vecAtoms.begin();itAtoms!=vecAtoms.end();itAtoms++)
{
out<<(*itAtoms)->getName()<<" ";
}
out<<endl;
}
}
Cgroup::nameId::nameId(string n):name(n)
{
// id=-100;
}
void Cgroup::nameId::setId(int i)
{
//cout <<"Add "<<i<<" after \n";
for (it=vecid.begin();it!=vecid.end();it++)
{
if(i>*it)
{
// cout <<*(it)<<" before "<<*(it-1)<<endl;
vecid.insert(it+1,i);
return;
}
}
vecid.push_back(i);
}
int Cgroup::nameId::getId(int i)
{
if (i<vecid.size()&&i>=0)
{
return vecid.at(i);
}
return -1000;
}