Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
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_MURMUR3_H | |
22 #define HASH_MURMUR3_H | |
23 | |
24 #include "hash-function.h" | |
25 | |
26 namespace ns3 { | |
27 ·· | |
28 namespace Hash { | |
29 | |
30 namespace Function { | |
31 | |
32 /** | |
33 * \ingroup hash | |
34 * | |
35 * \brief Murmur3 hash function implementation | |
36 * | |
37 * Adapted from http://code.google.com/p/smhasher/ | |
38 * | |
39 * MurmurHash3 was written by Austin Appleby, and is placed in the public | |
40 * domain. The author hereby disclaims copyright to this source code. | |
41 | |
42 * Note - The x86 and x64 versions do _not_ produce the same results, as the | |
43 * algorithms are optimized for their respective platforms. You can still | |
44 * compile and run any of them on any platform, but your performance with the | |
45 * non-native version will be less than optimal. | |
46 */ | |
47 class Murmur3 : public Implementation | |
48 { | |
49 public: | |
50 /** | |
51 * Compute 32-bit hash of a byte buffer | |
52 * | |
53 * \param [in] buffer pointer to the beginning of the buffer | |
54 * \param [in] size length of the buffer, in bytes | |
55 * \return 32-bit hash of the buffer | |
56 */ | |
57 Hash32_t GetHash32 (const char * buffer, const size_t size); | |
58 /** | |
59 * Compute 64-bit hash of a byte buffer. | |
60 * | |
61 * \param [in] buffer pointer to the beginning of the buffer | |
62 * \param [in] size length of the buffer, in bytes | |
63 * \return 64-bit hash of the buffer | |
64 */ | |
65 Hash64_t GetHash64 (const char * buffer, const size_t size); | |
66 /** | |
67 * Restore initial state | |
Jeff Y
2012/07/23 14:19:42
Might be useful to indicate here that Murmur doesn
Peter Barnes
2012/07/23 18:45:29
Will implement incremental hashing interface.
| |
68 */ | |
69 virtual void clear (void); | |
70 | |
71 private: | |
72 /** | |
73 * Seed value | |
74 * | |
75 * This has to be a constant for all MPI ranks to generate | |
76 * the same hash from the same string. | |
77 */ | |
78 enum seed | |
79 { | |
80 SEED = 0x8BADF00D // Ate bad food | |
81 }; | |
82 | |
83 }; // class Murmur3 | |
84 | |
85 } // namespace Function | |
86 ···· | |
87 } // namespace Hash | |
88 ·· | |
89 } // namespace ns3 | |
90 | |
91 #endif /* HASH_MURMUR3_H */ | |
OLD | NEW |