Add a simple 32 bit to 32 bit hash function (MurmurHash3)
This commit is contained in:
@@ -11,6 +11,7 @@ add_files(
|
|||||||
endian_func.hpp
|
endian_func.hpp
|
||||||
endian_type.hpp
|
endian_type.hpp
|
||||||
enum_type.hpp
|
enum_type.hpp
|
||||||
|
hash_func.hpp
|
||||||
geometry_func.cpp
|
geometry_func.cpp
|
||||||
geometry_func.hpp
|
geometry_func.hpp
|
||||||
geometry_type.hpp
|
geometry_type.hpp
|
||||||
|
28
src/core/hash_func.hpp
Normal file
28
src/core/hash_func.hpp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file hash_func.hpp Functions related to hashing operations. */
|
||||||
|
|
||||||
|
#ifndef HASH_FUNC_HPP
|
||||||
|
#define HASH_FUNC_HPP
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple 32 bit to 32 bit hash
|
||||||
|
* From MurmurHash3
|
||||||
|
*/
|
||||||
|
inline uint32 SimpleHash32(uint32 h)
|
||||||
|
{
|
||||||
|
h ^= h >> 16;
|
||||||
|
h *= 0x85ebca6b;
|
||||||
|
h ^= h >> 13;
|
||||||
|
h *= 0xc2b2ae35;
|
||||||
|
h ^= h >> 16;
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HASH_FUNC_HPP */
|
Reference in New Issue
Block a user