// Copyright (C) 2013-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include #include #include #include /* * @see http://code.google.com/p/smhasher/ */ #define SMHASHER_SEED_VALUE 0xc70f6907UL namespace std { size_t hash >::operator()(const pair& t) const { const char* a = t.first; const char* b = t.second; assert(a); assert(b); uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a, static_cast(strlen(a)), seed, &seed); MurmurHash3_x86_32(b, static_cast(strlen(b)), seed, &seed); return static_cast(seed); } size_t hash::operator()(const char* const t) const { uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(t, static_cast(strlen(t)), seed, &seed); return static_cast(seed); } size_t hash >::operator()(const pair& t) const { const string& a = t.first; const string& b = t.second; uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a.c_str(), static_cast(a.length()), seed, &seed); MurmurHash3_x86_32(b.c_str(), static_cast(b.length()), seed, &seed); return static_cast(seed); } size_t hash >::operator()(const tuple& t) const { const string& a = get<0>(t); const string& b = get<1>(t); const string& c = get<2>(t); uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a.c_str(), static_cast(a.length()), seed, &seed); MurmurHash3_x86_32(b.c_str(), static_cast(b.length()), seed, &seed); MurmurHash3_x86_32(c.c_str(), static_cast(c.length()), seed, &seed); return static_cast(seed); } size_t hash >::operator()(const tuple& t) const { const string& a = get<0>(t); const string& b = get<1>(t); const string& c = get<2>(t); const bool d = get<3>(t); uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a.c_str(), static_cast(a.length()), seed, &seed); MurmurHash3_x86_32(b.c_str(), static_cast(b.length()), seed, &seed); MurmurHash3_x86_32(c.c_str(), static_cast(c.length()), seed, &seed); MurmurHash3_x86_32(&d, sizeof(bool), seed, &seed); return static_cast(seed); } size_t hash >::operator()(const tuple& t) const { const string& a = get<0>(t); const string& b = get<1>(t); const string& c = get<2>(t); const int d = get<3>(t); uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a.c_str(), static_cast(a.length()), seed, &seed); MurmurHash3_x86_32(b.c_str(), static_cast(b.length()), seed, &seed); MurmurHash3_x86_32(c.c_str(), static_cast(c.length()), seed, &seed); MurmurHash3_x86_32(&d, sizeof(d), seed, &seed); return static_cast(seed); } size_t hash >::operator()(const tuple& t) const { const string& a = get<0>(t); const string& b = get<1>(t); const string& c = get<2>(t); const string& d = get<3>(t); uint32_t seed = static_cast(SMHASHER_SEED_VALUE); MurmurHash3_x86_32(a.c_str(), static_cast(a.length()), seed, &seed); MurmurHash3_x86_32(b.c_str(), static_cast(b.length()), seed, &seed); MurmurHash3_x86_32(c.c_str(), static_cast(c.length()), seed, &seed); MurmurHash3_x86_32(d.c_str(), static_cast(d.length()), seed, &seed); return static_cast(seed); } bool equal_to >::operator()(const pair& a, const pair& b) const { if (a.first == b.first && a.second == b.second) return true; return !strcmp(a.first, b.first) && !strcmp(a.second, b.second); } } // namespace std