-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBF_Bin.h
66 lines (55 loc) · 1.46 KB
/
BF_Bin.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
#include <iostream>
#include <iomanip>
class BF_Bin // adapted from the slide lecture
{
private:
int index;
double rc; // remaining capacity
double brc; // best remaining capacity
public:
BF_Bin() = default;
BF_Bin(const BF_Bin& other)
{
index = other.index;
rc = other.rc;
brc = other.brc;
}
BF_Bin(int index, double rc, double brc)
{
this->index = index;
this->rc = rc;
this->brc = brc;
}
double get_BRC() const
{
return brc;
}
double get_RC() const
{
return rc;
}
int get_index() const
{
return index;
}
bool operator<(const BF_Bin& other) const
{
return (rc < other.rc || (rc == other.rc && index < other.index));
}
bool operator>(const BF_Bin &other) const
{
return (rc > other.rc || (rc == other.rc && index > other.index));
}
void set_RC(double new_rc)
{
this->rc = new_rc;
}
void set_BRC(double new_brc)
{
this->brc = new_brc;
}
void print() const {
std::cout << std::fixed << rc << " "<<index << " " << brc << " " ;
}
~BF_Bin(){}
};