-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkvpair.hpp
38 lines (36 loc) · 871 Bytes
/
kvpair.hpp
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 kvpair_hpp
#define kvpair_hpp
template <class K, class V>
class KVPair {
private:
K _key;
V _value;
bool _empty;
public:
KVPair(K k, V v) {
_key = k;
_value = v;
_empty = false;
}
KVPair() { _empty = true; }
void clear() {
_empty = true;
_key = K();
_value = V();
}
bool operator==(const KVPair& o) const {
if (_empty && o._empty)
return true;
return _key == o._key;
}
bool operator!=(const KVPair& o) const {
return !(*this==o);
}
const K& key() const { return _key; }
V& value() { return _value; }
bool empty() { return _empty; }
void setValue(V val) {
_value = val;
}
};
#endif