Antonie
Defines | Functions
hash.c File Reference
#include "hash.h"

Defines

#define HASH_LITTLE_ENDIAN   1
#define HASH_BIG_ENDIAN   0
#define hashsize(n)   ((uint32_t)1<<(n))
#define hashmask(n)   (hashsize(n)-1)
#define rot(x, k)   (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a, b, c)
#define final(a, b, c)

Functions

uint32_t hash_u32 (const uint32_t *k, size_t length, uint32_t initval)
 hash_u32 - fast hash an array of 32-bit values for internal use : the array of uint32_t : the number of elements to hash : the base number to roll into the hash (usually 0)
uint64_t hash64_stable_64 (const void *key, size_t n, uint64_t base)
uint64_t hash64_stable_32 (const void *key, size_t n, uint64_t base)
uint64_t hash64_stable_16 (const void *key, size_t n, uint64_t base)
uint64_t hash64_stable_8 (const void *key, size_t n, uint64_t base)
uint32_t hash_any (const void *key, size_t length, uint32_t base)
uint32_t hash_stable_64 (const void *key, size_t n, uint32_t base)
uint32_t hash_stable_32 (const void *key, size_t n, uint32_t base)
uint32_t hash_stable_16 (const void *key, size_t n, uint32_t base)
uint32_t hash_stable_8 (const void *key, size_t n, uint32_t base)
uint64_t hash64_any (const void *key, size_t length, uint64_t base)

Define Documentation

#define final (   a,
  b,
 
)
Value:
{ \
  c ^= b; c -= rot(b,14); \
  a ^= c; a -= rot(c,11); \
  b ^= a; b -= rot(a,25); \
  c ^= b; c -= rot(b,16); \
  a ^= c; a -= rot(c,4);  \
  b ^= a; b -= rot(a,14); \
  c ^= b; c -= rot(b,24); \
}
#define HASH_BIG_ENDIAN   0
#define HASH_LITTLE_ENDIAN   1
#define hashmask (   n)    (hashsize(n)-1)
#define hashsize (   n)    ((uint32_t)1<<(n))
#define mix (   a,
  b,
 
)
Value:
{ \
  a -= c;  a ^= rot(c, 4);  c += b; \
  b -= a;  b ^= rot(a, 6);  a += c; \
  c -= b;  c ^= rot(b, 8);  b += a; \
  a -= c;  a ^= rot(c,16);  c += b; \
  b -= a;  b ^= rot(a,19);  a += c; \
  c -= b;  c ^= rot(b, 4);  b += a; \
}
#define rot (   x,
 
)    (((x)<<(k)) | ((x)>>(32-(k))))

Function Documentation

uint64_t hash64_any ( const void *  key,
size_t  length,
uint64_t  base 
)
uint64_t hash64_stable_16 ( const void *  key,
size_t  n,
uint64_t  base 
)
uint64_t hash64_stable_32 ( const void *  key,
size_t  n,
uint64_t  base 
)
uint64_t hash64_stable_64 ( const void *  key,
size_t  n,
uint64_t  base 
)
uint64_t hash64_stable_8 ( const void *  key,
size_t  n,
uint64_t  base 
)
uint32_t hash_any ( const void *  key,
size_t  length,
uint32_t  base 
)
uint32_t hash_stable_16 ( const void *  key,
size_t  n,
uint32_t  base 
)
uint32_t hash_stable_32 ( const void *  key,
size_t  n,
uint32_t  base 
)
uint32_t hash_stable_64 ( const void *  key,
size_t  n,
uint32_t  base 
)
uint32_t hash_stable_8 ( const void *  key,
size_t  n,
uint32_t  base 
)
uint32_t hash_u32 ( const uint32_t *  key,
size_t  num,
uint32_t  base 
)

hash_u32 - fast hash an array of 32-bit values for internal use : the array of uint32_t : the number of elements to hash : the base number to roll into the hash (usually 0)

The array of uint32_t pointed to by is combined with the base to form a 32-bit hash. This is 2-3 times faster than hash() on small arrays, but the advantage vanishes over large hashes.

This hash will have different results on different machines, so is only useful for internal hashes (ie. not hashes sent across the network or saved to disk).

 All Classes Files Functions Variables Typedefs Friends Defines