00001 /* 00002 * Copyright (C) Sergey P. Derevyago, 2008-2009. 00003 * 00004 * Permission to copy, use, modify, sell and distribute this software is granted 00005 * provided this copyright notice appears in all copies. 00006 * This software is provided "as is" without express or implied warranty, and 00007 * with no claim as to its suitability for any purpose. 00008 * 00009 */ 00010 00015 #include <ders/hash_vec.hpp> 00016 00017 namespace ders { // ::ders 00018 00019 namespace detail { // ::ders::detail 00020 00021 size_t calc_hash(const void* ptr, int n) 00022 { 00023 assert(n>=0); 00024 00025 size_t ret=0; 00026 for (const unsigned char *beg=static_cast<const unsigned char*>(ptr), 00027 *end=beg+n; beg!=end; beg++) 00028 ret=ret*5+*beg; 00029 00030 return ret; 00031 } 00032 00033 } // namespace ::ders::detail 00034 00035 } // namespace ::ders 00036