Make hash functions equality comparable.

This commit is contained in:
Matthias Vallentin 2013-07-22 18:03:55 +02:00
parent 9c2f57a9d9
commit eb64f5f961
3 changed files with 93 additions and 38 deletions

View file

@ -58,6 +58,7 @@
#define H3_H
#include <climits>
#include <cstring>
// The number of values representable by a byte.
#define H3_BYTE_RANGE (UCHAR_MAX+1)
@ -112,6 +113,17 @@ public:
return result;
}
friend bool operator==(const H3& x, const H3& y)
{
return ! std::memcmp(x.byte_lookup, y.byte_lookup, N * H3_BYTE_RANGE);
}
friend bool operator!=(const H3& x, const H3& y)
{
return ! (x == y);
}
private:
T byte_lookup[N][H3_BYTE_RANGE];
};