-
Notifications
You must be signed in to change notification settings - Fork 13
/
test2.cpp
39 lines (35 loc) · 986 Bytes
/
test2.cpp
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
//------------------------------- test2.cpp ------------------------------------
//
// 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.
//
//------------------------------------------------------------------------------
#include "X.h"
#include "fnv1a.h"
#include <cassert>
std::size_t
hash_contiguous(int (&data)[3])
{
acme::fnv1a h;
h(data, sizeof(data));
return static_cast<std::size_t>(h);
}
std::size_t
hash_discontiguous(int data1, int data2, int data3)
{
acme::fnv1a h;
h(&data1, sizeof(data1));
h(&data2, sizeof(data2));
h(&data3, sizeof(data3));
return static_cast<std::size_t>(h);
}
int
main()
{
int data[] = {5, 3, 8};
assert((hash_contiguous(data) == hash_discontiguous(5, 3, 8)));
}