-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stop.cpp
60 lines (47 loc) · 1.06 KB
/
Stop.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
#include <stdlib.h>
#include "Stop.h"
Stop::Stop(){
nodeId = -1;
numWalks = 0;
walkLength = 0;
};
Stop::Stop(int isNodeId, Interval isInterval){
nodeId = isNodeId;
interval = isInterval;
numWalks = 0;
walkLength = 0;
}
void Stop::reset(){
nodeId = -1;
numWalks = 0;
walkLength = 0;
}
int Stop::getNodeId(){
return nodeId;
}
void Stop::setNodeId(int isNodeId){
nodeId = isNodeId;
}
void Stop::setStartTime(int isStartTime){
interval.setStartTime(isStartTime);
}
void Stop::setEndTime(int isEndTime){
interval.setEndTime(isEndTime);
}
int Stop::getStartTime(){
return interval.getStartTime();
}
int Stop::getEndTime(){
return interval.getEndTime();
}
int Stop::intersect(Stop other){
if (!(nodeId == other.nodeId)) return 0;
if (!interval.doesOverlap(&(other.interval))) return 0;
int s = interval.getStartTime(), e = interval.getEndTime();
if (s < other.getStartTime()) s = other.getStartTime();
if (other.getEndTime() != -1){
if (e == -1) e = other.getEndTime();
else if (e > other.getEndTime()) e = other.getEndTime();
}
return (e - s + 1);
}