1
#ifndef __JEKINS_HASH_H__
2
#define __JEKINS_HASH_H__
6
typedef struct __jenkins_state_t
12
jenkins_state_t *jenkins_state_new(cmph_uint32 size); //size of hash table
14
/** \fn cmph_uint32 jenkins_hash(jenkins_state_t *state, const char *k, cmph_uint32 keylen);
15
* \param state is a pointer to a jenkins_state_t structure
16
* \param key is a pointer to a key
17
* \param keylen is the key length
18
* \return an integer that represents a hash value of 32 bits.
20
cmph_uint32 jenkins_hash(jenkins_state_t *state, const char *k, cmph_uint32 keylen);
22
/** \fn void jenkins_hash_vector_(jenkins_state_t *state, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);
23
* \param state is a pointer to a jenkins_state_t structure
24
* \param key is a pointer to a key
25
* \param keylen is the key length
26
* \param hashes is a pointer to a memory large enough to fit three 32-bit integers.
28
void jenkins_hash_vector_(jenkins_state_t *state, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);
30
void jenkins_state_dump(jenkins_state_t *state, char **buf, cmph_uint32 *buflen);
31
jenkins_state_t *jenkins_state_copy(jenkins_state_t *src_state);
32
jenkins_state_t *jenkins_state_load(const char *buf, cmph_uint32 buflen);
33
void jenkins_state_destroy(jenkins_state_t *state);
35
/** \fn void jenkins_state_pack(jenkins_state_t *state, void *jenkins_packed);
36
* \brief Support the ability to pack a jenkins function into a preallocated contiguous memory space pointed by jenkins_packed.
37
* \param state points to the jenkins function
38
* \param jenkins_packed pointer to the contiguous memory area used to store the jenkins function. The size of jenkins_packed must be at least jenkins_state_packed_size()
40
void jenkins_state_pack(jenkins_state_t *state, void *jenkins_packed);
42
/** \fn cmph_uint32 jenkins_state_packed_size();
43
* \brief Return the amount of space needed to pack a jenkins function.
44
* \return the size of the packed function or zero for failures
46
cmph_uint32 jenkins_state_packed_size(void);
49
/** \fn cmph_uint32 jenkins_hash_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen);
50
* \param jenkins_packed is a pointer to a contiguous memory area
51
* \param key is a pointer to a key
52
* \param keylen is the key length
53
* \return an integer that represents a hash value of 32 bits.
55
cmph_uint32 jenkins_hash_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen);
57
/** \fn jenkins_hash_vector_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);
58
* \param jenkins_packed is a pointer to a contiguous memory area
59
* \param key is a pointer to a key
60
* \param keylen is the key length
61
* \param hashes is a pointer to a memory large enough to fit three 32-bit integers.
63
void jenkins_hash_vector_packed(void *jenkins_packed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);