mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 12:38:20 +00:00
Make hash functions equality comparable.
This commit is contained in:
parent
9c2f57a9d9
commit
eb64f5f961
3 changed files with 93 additions and 38 deletions
12
src/H3.h
12
src/H3.h
|
@ -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];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue