/* Copyright (C) 2013 BMW Group * Author: Manfred Bathelt (manfred.bathelt@bmw.de) * Author: Juergen Gehring (juergen.gehring@bmw.de) * 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 "DBusFunctionalHash.h" #include #include #include /* * @see http://code.google.com/p/smhasher/ */ #define SMHASHER_SEED_VALUE 0xc70f6907UL namespace std { size_t hash< pair >::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, strlen(a), seed, &seed); MurmurHash3_x86_32(b, strlen(b), seed, &seed); return static_cast(seed); } size_t hash< pair >::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(), a.length(), seed, &seed); MurmurHash3_x86_32(b.c_str(), b.length(), seed, &seed); return static_cast(seed); } size_t hash< tuple >::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(), a.length(), seed, &seed); MurmurHash3_x86_32(b.c_str(), b.length(), seed, &seed); MurmurHash3_x86_32(c.c_str(), c.length(), seed, &seed); return static_cast(seed); } size_t hash< tuple >::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(), a.length(), seed, &seed); MurmurHash3_x86_32(b.c_str(), b.length(), seed, &seed); MurmurHash3_x86_32(c.c_str(), c.length(), seed, &seed); MurmurHash3_x86_32(&d, sizeof(bool), seed, &seed); return static_cast(seed); } size_t hash< tuple >::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(), a.length(), seed, &seed); MurmurHash3_x86_32(b.c_str(), b.length(), seed, &seed); MurmurHash3_x86_32(c.c_str(), c.length(), seed, &seed); MurmurHash3_x86_32(&d, sizeof(d), seed, &seed); return static_cast(seed); } size_t hash< tuple >::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(), a.length(), seed, &seed); MurmurHash3_x86_32(b.c_str(), b.length(), seed, &seed); MurmurHash3_x86_32(c.c_str(), c.length(), seed, &seed); MurmurHash3_x86_32(d.c_str(), d.length(), seed, &seed); return static_cast(seed); } bool equal_to< pair >::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