Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / girepository / cmph / chd.h
1 #ifndef _CMPH_CHD_H__
2 #define _CMPH_CHD_H__
3
4 #include "cmph.h"
5
6 typedef struct __chd_data_t chd_data_t;
7 typedef struct __chd_config_data_t chd_config_data_t;
8
9 /* Config API */
10 chd_config_data_t *chd_config_new(cmph_config_t * mph);
11 void chd_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs);
12
13 /** \fn void chd_config_set_keys_per_bin(cmph_config_t *mph, cmph_uint32 keys_per_bin);
14  *  \brief Allows to set the number of keys per bin.
15  *  \param mph pointer to the configuration structure
16  *  \param keys_per_bin value for the number of keys per bin 
17  */
18 void chd_config_set_keys_per_bin(cmph_config_t *mph, cmph_uint32 keys_per_bin);
19
20 /** \fn void chd_config_set_b(cmph_config_t *mph, cmph_uint32 keys_per_bucket);
21  *  \brief Allows to set the number of keys per bucket.
22  *  \param mph pointer to the configuration structure
23  *  \param keys_per_bucket value for the number of keys per bucket 
24  */
25 void chd_config_set_b(cmph_config_t *mph, cmph_uint32 keys_per_bucket);
26 void chd_config_destroy(cmph_config_t *mph);
27
28
29 /* Chd algorithm API */
30 cmph_t *chd_new(cmph_config_t *mph, double c);
31 void chd_load(FILE *fd, cmph_t *mphf);
32 int chd_dump(cmph_t *mphf, FILE *fd);
33 void chd_destroy(cmph_t *mphf);
34 cmph_uint32 chd_search(cmph_t *mphf, const char *key, cmph_uint32 keylen);
35
36 /** \fn void chd_pack(cmph_t *mphf, void *packed_mphf);
37  *  \brief Support the ability to pack a perfect hash function into a preallocated contiguous memory space pointed by packed_mphf.
38  *  \param mphf pointer to the resulting mphf
39  *  \param packed_mphf pointer to the contiguous memory area used to store the resulting mphf. The size of packed_mphf must be at least cmph_packed_size() 
40  */
41 void chd_pack(cmph_t *mphf, void *packed_mphf);
42
43 /** \fn cmph_uint32 chd_packed_size(cmph_t *mphf);
44  *  \brief Return the amount of space needed to pack mphf.
45  *  \param mphf pointer to a mphf
46  *  \return the size of the packed function or zero for failures
47  */ 
48 cmph_uint32 chd_packed_size(cmph_t *mphf);
49
50 /** cmph_uint32 chd_search(void *packed_mphf, const char *key, cmph_uint32 keylen);
51  *  \brief Use the packed mphf to do a search. 
52  *  \param  packed_mphf pointer to the packed mphf
53  *  \param key key to be hashed
54  *  \param keylen key legth in bytes
55  *  \return The mphf value
56  */
57 cmph_uint32 chd_search_packed(void *packed_mphf, const char *key, cmph_uint32 keylen);
58
59 #endif