2018-07-21 16:13:18 +02:00
|
|
|
#ifndef KV_H
|
|
|
|
#define KV_H
|
|
|
|
|
2019-08-01 08:36:58 +02:00
|
|
|
template <class KEY, class VALUE>
|
2018-07-21 16:13:18 +02:00
|
|
|
class KV {
|
|
|
|
public:
|
2023-05-13 15:01:35 +02:00
|
|
|
KV() {}
|
2019-08-01 08:36:58 +02:00
|
|
|
KV(const KEY &key, const VALUE &value) : _key(key), _value(value) {}
|
2018-07-21 16:13:18 +02:00
|
|
|
|
2019-08-01 08:36:58 +02:00
|
|
|
const KEY &key() const {return _key;}
|
|
|
|
const VALUE &value() const {return _value;}
|
2018-07-21 16:13:18 +02:00
|
|
|
|
2021-08-04 08:57:42 +02:00
|
|
|
bool operator==(const KV &other) const
|
|
|
|
{
|
|
|
|
return (_key == other._key && _value == other._value);
|
|
|
|
}
|
|
|
|
bool operator<(const KV &other) const
|
|
|
|
{
|
|
|
|
if (_key < other._key)
|
|
|
|
return true;
|
|
|
|
else if (_key > other._key)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return _value < other._value;
|
|
|
|
}
|
2018-07-21 16:13:18 +02:00
|
|
|
|
|
|
|
private:
|
2019-08-01 08:36:58 +02:00
|
|
|
KEY _key;
|
|
|
|
VALUE _value;
|
2018-07-21 16:13:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KV_H
|