-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflow.cpp
More file actions
55 lines (51 loc) · 1.21 KB
/
flow.cpp
File metadata and controls
55 lines (51 loc) · 1.21 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
#include "flow.h"
#include "header.h"
#define PATH0 "../../Share/flow.txt"
void GetFlowFromFile(vector<Flow*>& flowSet)
{
ifstream in(PATH0);
while (!in.eof())
{
int src = -1, dst, arrivalTime;
double size;
in >> src >> dst >> size >> arrivalTime;
if (src >= 0)
{
Flow* flow = new Flow(src, dst, size, arrivalTime);
flowSet.push_back(flow);
}
}
in.close();
cout << "GetFlowFromFile() succeeds !!!" << endl;
}
void SplitFlows(vector<Flow*>& flowSet, vector<Flow*>& largeFlows, vector<Flow*>& smallFlows)
{
for (int i = 0; i < flowSet.size(); i++)
{
Flow* flow = flowSet[i];
if (flow->isLargeFlow == true)
{
largeFlows.push_back(flow);
}
else
{
smallFlows.push_back(flow);
}
}
cout << "SplitFlows() succeeds !!!" << endl;
}
void UpdateFlows(vector<Flow*>& largeFlows, vector<Flow*>& smallFlows)
{
for (vector<Flow*>::iterator flowIt = largeFlows.begin(); flowIt != largeFlows.end(); flowIt ++)
{
(*flowIt)->totalSize *= HOTSPOT_X;
(*flowIt)->currentSize *= HOTSPOT_X;
}
int num = (int)(largeFlows.size() * HOTSPOT_Y);
for (int i = 0; i < num; i++)
{
largeFlows[i]->totalSize *= 10;
largeFlows[i]->currentSize *= 10;
}
cout << "UpdateFlows() succeeds !!!" << endl;
}