mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Add equality, inequality, copy, and move operators to HashKey
This commit is contained in:
parent
a5b2e44e57
commit
3b69dd38f3
2 changed files with 154 additions and 5 deletions
24
src/Hash.h
24
src/Hash.h
|
@ -255,11 +255,14 @@ public:
|
|||
// function from the one above; its value is not used.
|
||||
HashKey(const void* key, size_t size, hash_t hash, bool dont_copy);
|
||||
|
||||
~HashKey()
|
||||
{
|
||||
if ( is_our_dynamic )
|
||||
delete[](char*) key;
|
||||
}
|
||||
// Copy constructor. Always copies the key.
|
||||
HashKey(const HashKey& other);
|
||||
|
||||
// Move constructor. Takes ownership of the key.
|
||||
HashKey(HashKey&& other) noexcept;
|
||||
|
||||
// Destructor
|
||||
~HashKey();
|
||||
|
||||
// Hands over the key to the caller. This means that if the
|
||||
// key is our dynamic, we give it to the caller and mark it
|
||||
|
@ -343,6 +346,17 @@ public:
|
|||
|
||||
void Describe(ODesc* d) const;
|
||||
|
||||
bool operator==(const HashKey& other) const;
|
||||
bool operator!=(const HashKey& other) const;
|
||||
|
||||
bool Equal(const void* other_key, size_t other_size, hash_t other_hash) const;
|
||||
|
||||
// Copy operator. Always copies the key.
|
||||
HashKey& operator=(const HashKey& other);
|
||||
|
||||
// Move operator. Takes ownership of the key.
|
||||
HashKey& operator=(HashKey&& other) noexcept;
|
||||
|
||||
protected:
|
||||
char* CopyKey(const char* key, size_t size) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue