10 template <
typename T,
int N>
13 static size_t const bits_per_byte =
14 std::numeric_limits<unsigned char>::digits;
17 constexpr
static size_t byte_range =
18 std::numeric_limits<unsigned char>::max() + 1;
22 T bits[N * bits_per_byte];
23 std::minstd_rand0 prng(seed);
24 for (
size_t bit = 0; bit < N * bits_per_byte; ++bit)
27 for (
size_t i = 0; i <
sizeof(T)/2; i++)
28 bits[bit] = (bits[bit] << 16) | (prng() & 0xFFFF);
31 for (
size_t byte = 0; byte < N; ++byte)
32 for (
size_t val = 0; val < byte_range; ++val)
34 bytes_[byte][val] = 0;
35 for (
size_t bit = 0; bit < bits_per_byte; ++bit)
37 bytes_[byte][val] ^= bits[byte * bits_per_byte + bit];
41 T operator()(
void const* data,
size_t size,
size_t offset = 0)
const
43 auto *p =
static_cast<unsigned char const*
>(data);
46 register auto n = (size + 7) / 8;
49 case 0:
do { result ^= bytes_[offset++][*p++];
50 case 7: result ^= bytes_[offset++][*p++];
51 case 6: result ^= bytes_[offset++][*p++];
52 case 5: result ^= bytes_[offset++][*p++];
53 case 4: result ^= bytes_[offset++][*p++];
54 case 3: result ^= bytes_[offset++][*p++];
55 case 2: result ^= bytes_[offset++][*p++];
56 case 1: result ^= bytes_[offset++][*p++];
63 T bytes_[N][byte_range];