X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fhash.cpp;fp=source%2Fcore%2Fhash.cpp;h=0000000000000000000000000000000000000000;hp=aed9ed19d2aa522c33b9e047c1d2bca7b89e87ec;hb=4ad05c650c55e3edccea887d15b26f41cdf60fb6;hpb=991fabc1956b73a4007859058fb44171000b452e diff --git a/source/core/hash.cpp b/source/core/hash.cpp deleted file mode 100644 index aed9ed1..0000000 --- a/source/core/hash.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include "hash.h" - -using namespace std; - -namespace Msp { - -/* -http://en.wikipedia.org/wiki/Fowler-Noll-Vo_hash_function -http://www.isthe.com/chongo/tech/comp/fnv/index.html -*/ - -uint32_t hash32(const void *data, unsigned size, unsigned bits) -{ - if(bits==0 || bits>32) - throw invalid_argument("hash32"); - - static const unsigned prime = 16777619; - static const unsigned offset = 2166136261U; - - unsigned result = offset; - for(unsigned i=0; i(data)+i))*prime; - - if(bits<32) - result = (result>>bits ^ result) & ((1<64) - throw invalid_argument("hash64"); - - static const uint64_t prime = 1099511628211ULL; - static const uint64_t offset = 14695981039346656037ULL; - - uint64_t result = offset; - for(unsigned i=0; i(data)+i))*prime; - - if(bits<64) - result = (result>>bits ^ result) & ((1ULL<