A Discrete-Event Network Simulator
API
hash-murmur3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Lawrence Livermore National Laboratory
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18  */
19 
20 #ifndef HASH_MURMUR3_H
21 #define HASH_MURMUR3_H
22 
23 #include "hash-function.h"
24 
31 namespace ns3
32 {
33 
34 namespace Hash
35 {
36 
37 namespace Function
38 {
39 
55 class Murmur3 : public Implementation
56 {
57  public:
61  Murmur3();
76  uint32_t GetHash32(const char* buffer, const std::size_t size) override;
91  uint64_t GetHash64(const char* buffer, const std::size_t size) override;
95  void clear() override;
96 
97  private:
104  static constexpr auto SEED{0x8BADF00D}; // Ate bad food
105 
111  uint32_t m_hash32;
112  std::size_t m_size32;
117  uint64_t m_hash64[2];
118  std::size_t m_size64;
121 }; // class Murmur3
122 
123 } // namespace Function
124 
125 } // namespace Hash
126 
127 } // namespace ns3
128 
129 #endif /* HASH_MURMUR3_H */
Murmur3 hash function implementation.
Definition: hash-murmur3.h:56
void clear() override
Restore initial state.
Murmur3()
Constructor, clears internal state.
std::size_t m_size32
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.
Definition: hash-murmur3.h:112
uint64_t m_hash64[2]
murmur3 produces 128-bit hash and state; we use just the first 64-bits.
Definition: hash-murmur3.h:117
uint32_t GetHash32(const char *buffer, const std::size_t size) override
Compute 32-bit hash of a byte buffer.
uint32_t m_hash32
Cache last hash value, and total bytes hashed (needed to finalize), for incremental hashing.
Definition: hash-murmur3.h:111
static constexpr auto SEED
Seed value.
Definition: hash-murmur3.h:104
uint64_t GetHash64(const char *buffer, const std::size_t size) override
Compute 64-bit hash of a byte buffer.
std::size_t m_size64
murmur3 produces 128-bit hash and state; we use just the first 64-bits.
Definition: hash-murmur3.h:118
Hash function implementation base class.
Definition: hash-function.h:50
ns3::Hash::Implementation, ns3::Hash::Function::Hash32 and ns3::Hash::Function::Hash64 declarations.
Every class exported by the ns3 library is enclosed in the ns3 namespace.