A Discrete-Event Network Simulator
API
hash-fnv.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 Lawrence Livermore National Laboratory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19  */
20 
21 #ifndef HASH_FNV_H
22 #define HASH_FNV_H
23 
24 #include "hash-function.h"
25 
32 namespace ns3 {
33 
34 namespace Hash {
35 
36 namespace Function {
37 
53 class Fnv1a : public Implementation
54 {
55 public:
59  Fnv1a ();
74  uint32_t GetHash32 (const char * buffer, const size_t size);
89  uint64_t GetHash64 (const char * buffer, const size_t size);
93  virtual void clear (void);
94 
95 private:
99  enum seed
100  {
101  SEED = 0x8BADF00D
102  };
105  uint32_t m_hash32;
106  uint64_t m_hash64;
109 }; // class Fnv1a
110 
111 } // namespace Function
112 
113 } // namespace Hash
114 
115 } // namespace ns3
116 
117 #endif /* HASH_FNV_H */
Fnv1a hash function implementation.
Definition: hash-fnv.h:54
uint64_t GetHash64(const char *buffer, const size_t size)
Compute 64-bit hash of a byte buffer.
Definition: hash-fnv.cc:763
uint32_t m_hash32
Cache last hash value, for incremental hashing.
Definition: hash-fnv.h:105
@ SEED
Ate bad food.
Definition: hash-fnv.h:101
virtual void clear(void)
Restore initial state.
Definition: hash-fnv.cc:771
uint64_t m_hash64
Cache last hash value, for incremental hashing.
Definition: hash-fnv.h:106
uint32_t GetHash32(const char *buffer, const size_t size)
Compute 32-bit hash of a byte buffer.
Definition: hash-fnv.cc:755
Hash function implementation base class.
Definition: hash-function.h:48
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.