-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPair.h
32 lines (27 loc) · 1.13 KB
/
MPair.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
#ifndef MPAIR_H
#define MPAIR_H
#include <vector>
#include <iostream>
template <typename k, typename v>
struct MPair {
k key;
std::vector<v> value_list;
// === CTORS === //
MPair(const k& d, const v& e) : key(d) {
value_list.push_back(e);}
MPair(const k& d = k(), const std::vector<v>& e = std::vector<v>()) :
key(d), value_list(e) {}
//INLINED
bool operator==(const MPair<k, v>& rhs) const {return key == rhs.key;}
bool operator!=(const MPair<k, v>& rhs) const {return key != rhs.key;}
bool operator<(const MPair<k, v>& rhs) const {return key < rhs.key;}
bool operator>(const MPair<k, v>& rhs) const {return key > rhs.key;}
bool operator<=(const MPair<k, v>& rhs) const {return key <= rhs.key;}
bool operator>=(const MPair<k, v>& rhs) const {return key >= rhs.key;}
friend std::ostream& operator <<(std::ostream& outs,
const MPair<k, v>& print_me) {
outs << '[' << print_me.key << '|' << print_me.value_list << ']';
return outs;
}
};
#endif // MPAIR_H