22#include <lal/LALHashFunc.h>
27 for (
int i = 0; i <
N; ++i) {
30 for (
int j = 0; j <= i; ++j) {
35 if (i != j && hi == hj) {
40 for (
int i = 0; i <
N; ++i) {
41 for (
int j = 0; j <= i; ++j) {
42 UINT8 hij = 0, hji = 0;
49 if (i != j && hij == hji) {
54 printf(
"XLALPearsonHash(hval=%zu) collisions in %i integer pairs: %i\n", hval_len, n, nc);
62 char buf1[5] = {0}, buf2[5] = {0};
63 for (buf1[0] =
'a'; buf1[0] <
'a' +
N; ++buf1[0]) {
64 for (buf1[1] =
'a'; buf1[1] <
'a' +
N; ++buf1[1]) {
65 for (buf1[2] =
'a'; buf1[2] <
'a' +
N; ++buf1[2]) {
66 for (buf1[3] =
'a'; buf1[3] <
'a' +
N; ++buf1[3]) {
68 for (buf2[0] =
'a'; buf2[0] <
'a' +
N; ++buf2[0]) {
69 for (buf2[1] =
'a'; buf2[1] <
'a' +
N; ++buf2[1]) {
70 for (buf2[2] =
'a'; buf2[2] <
'a' +
N; ++buf2[2]) {
71 for (buf2[3] =
'a'; buf2[3] <
'a' +
N; ++buf2[3]) {
74 if (strcmp(buf1, buf2) != 0 && h1 == h2) {
85 printf(
"XLALCityHash() collisions in %i strings with %i letters: %i\n", n,
N, nc);
static int test_XLALPearsonHash(size_t hval_len, const int N, const int nc_ref)
static int test_XLALCityHash(const char N, const int nc_ref)
void LALCheckMemoryLeaks(void)
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
uint16_t UINT2
Two-byte unsigned integer.
uint32_t UINT4
Four-byte unsigned integer.
int XLALPearsonHash(void *hval, const size_t hval_len, const void *data, const size_t data_len)
Compute a arbitrary-sized Pearson hash value for the given arbitrary data.
UINT8 XLALCityHash64(const char *s, size_t len)
Hash function for a byte array.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_MAIN(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a C main() routine.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
@ XLAL_EFAILED
Generic failure.