ultimatepp/uppsrc/Core/xxHsh.cpp
cxl 2ccfe7ab06 Core: Huge, changes in ValueType(No), HashBySerialize, IsEqualBySerialize, GetHashValue for containers
git-svn-id: svn://ultimatepp.org/upp/trunk@10008 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-07-05 14:46:57 +00:00

42 lines
No EOL
700 B
C++

#include "Core.h"
#include "lib/xxhash.h"
namespace Upp {
xxHashStream::xxHashStream(dword seed)
{
STATIC_ASSERT(sizeof(context) >= sizeof(XXH32_state_t));
Reset(seed);
}
void xxHashStream::Reset(dword seed)
{
XXH32_reset((XXH32_state_t *)context, seed);
}
void xxHashStream::Out(const void *data, dword size)
{
RTIMING("xxHash");
XXH32_update((XXH32_state_t *)context, data, size);
}
int xxHashStream::Finish()
{
Flush();
return XXH32_digest((XXH32_state_t *)context);
}
int xxHash(const void *data, size_t len)
{
xxHashStream h;
h.Put64(data, len);
return h.Finish();
}
int xxHash(const String& s)
{
return xxHash(~s, s.GetCount());
}
};