-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathspooky.h
54 lines (44 loc) · 1.21 KB
/
spooky.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//------------------------------- spooky.h -------------------------------------
//
// This software is in the public domain. The only restriction on its use is
// that no one can remove it from the public domain by claiming ownership of it,
// including the original authors.
//
// There is no warranty of correctness on the software contained herein. Use
// at your own risk.
//
//------------------------------------------------------------------------------
#ifndef SPOOKY_H
#define SPOOKY_H
#include "endian.h"
#include <cstddef>
#include <cstdint>
#include "SpookyV2.h"
// namespace acme is used to demonstrate example code. It is not proposed.
namespace acme
{
class spooky
{
SpookyHash state_;
public:
static constexpr xstd::endian endian = xstd::endian::native;
using result_type = std::size_t;
spooky(std::size_t seed1 = 1, std::size_t seed2 = 2) noexcept
{
state_.Init(seed1, seed2);
}
void
operator()(void const* key, std::size_t len) noexcept
{
state_.Update(key, len);
}
explicit
operator result_type() noexcept
{
std::uint64_t h1, h2;
state_.Final(&h1, &h2);
return h1;
}
};
} // acme
#endif // SPOOKY_H