8 #ifndef INCL_evo_pair_h 9 #define INCL_evo_pair_h 31 template<
class TA,
class TB>
62 Pair(
const TA&
a,
const TB&
b) : first(a), second(b) {
68 Pair(
const This& src) : first(src.first), second(src.second) {
81 #if defined(EVO_CPP11) 85 Pair(This&& src) : first(std::move(src.first)), second(std::move(src.second)) {
93 first = std::move(src.first);
94 second = std::move(src.second);
151 ulong
hash(ulong seed=0)
const {
176 {
return (first == src.
first && second == src.
second); }
185 {
return (first != src.
first || second != src.
second); }
194 {
return (first < src.
first || (first == src.
first && second < src.
second)); }
203 {
return (first < src.
first || (first == src.
first && second <= src.
second)); }
212 {
return (first > src.
first || (first == src.
first && second > src.
second)); }
220 {
return (first > src.
first || (first == src.
first && second >= src.
second)); }
bool operator<=(const This &src) const
Compare whether less than or equal to given pair.
Definition: pair.h:202
const A & a() const
Get first value (const).
Definition: pair.h:102
This & operator=(const This &src)
Assignment operator.
Definition: pair.h:75
bool operator>(const This &src) const
Compare whether greater than given pair.
Definition: pair.h:211
bool operator==(const This &src) const
Compare for equality.
Definition: pair.h:175
Pair(const This &src)
Copy constructor.
Definition: pair.h:68
const B & b() const
Get second value (const).
Definition: pair.h:126
TA A
First value type (same as Key)
Definition: pair.h:35
Pair(This &&src)
Move constructor (C++11).
Definition: pair.h:85
A & a()
Get first value.
Definition: pair.h:108
TB Value
Pair value type (same as B)
Definition: pair.h:40
TA first
First value (same as a() and key())
Definition: pair.h:42
static void set_default_pod(T &val)
Set new POD value to default value (0).
Definition: container.h:569
const Value & value() const
Get value for pair (second value) (const).
Definition: pair.h:138
TA First
First value type (same as Key)
Definition: pair.h:36
TB Second
Second value type (same as Value)
Definition: pair.h:39
bool operator!=(const This &src) const
Compare for inequality.
Definition: pair.h:184
Evo container foundation types and macros.
static ulong hash(const T *data, ulong size, ulong seed=0)
Compute hash value from data.
Definition: container.h:899
int compare(const This &src) const
Compare with another instance.
Definition: pair.h:162
Pair()
Constructor.
Definition: pair.h:46
Evo C++ Library namespace.
Definition: alg.h:11
B & b()
Get second value.
Definition: pair.h:132
Pair(const TA &a)
Constructor.
Definition: pair.h:54
const Key & key() const
Get key for pair (first value) (const).
Definition: pair.h:114
Key & key()
Get key for pair (first value).
Definition: pair.h:120
static int compare(const T *data1, ulong size1, const T *data2, ulong size2)
Compare data.
Definition: container.h:769
Pair< TA, TB > This
This type.
Definition: pair.h:33
TB B
Second value type (same as Value)
Definition: pair.h:38
TA Key
Pair key type (same as A)
Definition: pair.h:37
Value & value()
Get value for pair (second value).
Definition: pair.h:144
bool operator>=(const This &src) const
Compare whether greater than or equal to given pair.
Definition: pair.h:219
Stores a key/value pair of independent objects or values.
Definition: pair.h:32
This & operator=(This &&src)
Move assignment operator (C++11).
Definition: pair.h:92
bool operator<(const This &src) const
Compare whether less than given pair.
Definition: pair.h:193
Pair(const TA &a, const TB &b)
Constructor.
Definition: pair.h:62
TB second
Second value (same as b() and value())
Definition: pair.h:43
ulong hash(ulong seed=0) const
Get hash value for both values in pair.
Definition: pair.h:151