From f038883a6e004eb4312ba1e761da06b596e14d3f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:43 +0200 Subject: tagging ychat-0.7.7.0 --- src/maps/hash.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/maps/hash.cpp (limited to 'src/maps/hash.cpp') diff --git a/src/maps/hash.cpp b/src/maps/hash.cpp new file mode 100644 index 0000000..b3d80d1 --- /dev/null +++ b/src/maps/hash.cpp @@ -0,0 +1,26 @@ +#ifndef HASH_CPP +#define HASH_CPP + +#include "hash.h" + +int +hash::operator()(string s_key) const +{ + int i_hash = 0; + // cout << key << "%"; + + int i_size = s_key.size(); + + for( size_t i = 0; i < i_size; ++i ) + i_hash = ( i_hash << 5 ) ^ s_key.at(i) ^ i_hash; + + return i_hash; +} + +bool +hashmap_allocator::operator()(string s_key_1, string s_key_2) const +{ + return s_key_1.compare(s_key_2) == 0; +} + +#endif -- cgit v1.2.3