-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntervalNode.cpp
38 lines (29 loc) · 976 Bytes
/
IntervalNode.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
#ifndef INTERVAL_NODE_CPP
#define INTERVAL_NODE_CPP
#include <memory>
#include "Interval.cpp"
class IntervalNode {
public:
using SharedPtr = std::shared_ptr<IntervalNode>;
using SharedVec = std::vector<std::shared_ptr<IntervalNode>>;
private:
SharedPtr left_;
SharedPtr right_;
Interval interval_;
public:
// * Constructors
IntervalNode() { interval_ = Interval(); }
// IntervalNode(Interval interval) { interval_ = interval; }
IntervalNode(double start, double end) { interval_ = Interval(start, end); }
bool isLeaf() {
if (left_ == nullptr && right_ == nullptr) {
return true;
}
return false;
}
// * Accessors
SharedPtr& left() {return left_; }
SharedPtr& right() { return right_; }
Interval& interval() { return interval_; }
};
#endif