aboutsummaryrefslogtreecommitdiff
path: root/dep/include/g3dlite/G3D/HashTrait.h
diff options
context:
space:
mode:
authorXanadu <none@none>2010-07-20 02:49:28 +0200
committerXanadu <none@none>2010-07-20 02:49:28 +0200
commit79622802f397258ee0f34327ba3ae6977ca3e7ff (patch)
tree1868946c234ab9ee256a6b7766a15713eae94235 /dep/include/g3dlite/G3D/HashTrait.h
parent7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff)
parentf906976837502fa5aa81b982b901d1509f5aa0c4 (diff)
Merge. Revision history for source files should be all back now.
--HG-- branch : trunk rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'dep/include/g3dlite/G3D/HashTrait.h')
-rw-r--r--dep/include/g3dlite/G3D/HashTrait.h92
1 files changed, 0 insertions, 92 deletions
diff --git a/dep/include/g3dlite/G3D/HashTrait.h b/dep/include/g3dlite/G3D/HashTrait.h
deleted file mode 100644
index ca35da48643..00000000000
--- a/dep/include/g3dlite/G3D/HashTrait.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- @file HashTrait.h
-
- @maintainer Morgan McGuire, http://graphics.cs.williams.edu
- @created 2008-10-01
- @edited 2009-11-01
-
- Copyright 2000-2009, Morgan McGuire.
- All rights reserved.
- */
-
-#ifndef G3D_HashTrait_h
-#define G3D_HashTrait_h
-
-#include "G3D/platform.h"
-#include "G3D/Crypto.h"
-#include "G3D/g3dmath.h"
-#include "G3D/uint128.h"
-
-/** Must be specialized for custom types.
- @see G3D::Table for specialization requirements.
-*/
-template <typename T> struct HashTrait{};
-
-template <typename T> struct HashTrait<T*> {
- static size_t hashCode(const void* k) { return reinterpret_cast<size_t>(k); }
-};
-
-#if 0
-template <> struct HashTrait <int> {
- static size_t hashCode(int k) { return static_cast<size_t>(k); }
-};
-#endif
-
-template <> struct HashTrait <G3D::int16> {
- static size_t hashCode(G3D::int16 k) { return static_cast<size_t>(k); }
-};
-
-template <> struct HashTrait <G3D::uint16> {
- static size_t hashCode(G3D::uint16 k) { return static_cast<size_t>(k); }
-};
-
-//template <> struct HashTrait <int> {
-// static size_t hashCode(int k) { return static_cast<size_t>(k); }
-//};
-
-template <> struct HashTrait <G3D::int32> {
- static size_t hashCode(G3D::int32 k) { return static_cast<size_t>(k); }
-};
-
-template <> struct HashTrait <G3D::uint32> {
- static size_t hashCode(G3D::uint32 k) { return static_cast<size_t>(k); }
-};
-
-#if 0
-template <> struct HashTrait <long unsigned int> {
- static size_t hashCode(G3D::uint32 k) { return static_cast<size_t>(k); }
-};
-#endif
-
-template <> struct HashTrait <G3D::int64> {
- static size_t hashCode(G3D::int64 k) { return static_cast<size_t>(k); }
-};
-
-template <> struct HashTrait <G3D::uint64> {
- static size_t hashCode(G3D::uint64 k) { return static_cast<size_t>(k); }
-};
-
-template <> struct HashTrait <std::string> {
- static size_t hashCode(const std::string& k) { return static_cast<size_t>(G3D::Crypto::crc32(k.c_str(), k.size())); }
-};
-
-template <> struct HashTrait<G3D::uint128> {
- // Use the FNV-1 hash (http://isthe.com/chongo/tech/comp/fnv/#FNV-1).
- static size_t hashCode(G3D::uint128 key) {
- static const G3D::uint128 FNV_PRIME_128(1 << 24, 0x159);
- static const G3D::uint128 FNV_OFFSET_128(0xCF470AAC6CB293D2ULL, 0xF52F88BF32307F8FULL);
-
- G3D::uint128 hash = FNV_OFFSET_128;
- G3D::uint128 mask(0, 0xFF);
- for (int i = 0; i < 16; ++i) {
- hash *= FNV_PRIME_128;
- hash ^= (mask & key);
- key >>= 8;
- }
-
- G3D::uint64 foldedHash = hash.hi ^ hash.lo;
- return static_cast<size_t>((foldedHash >> 32) ^ (foldedHash & 0xFFFFFFFF));
- }
-};
-
-#endif