Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / girepository / cmph / chm.h
1 #ifndef __CMPH_CHM_H__
2 #define __CMPH_CHM_H__
3
4 #include "cmph.h"
5
6 typedef struct __chm_data_t chm_data_t;
7 typedef struct __chm_config_data_t chm_config_data_t;
8
9 chm_config_data_t *chm_config_new(void);
10 void chm_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs);
11 void chm_config_destroy(cmph_config_t *mph);
12 cmph_t *chm_new(cmph_config_t *mph, double c);
13
14 void chm_load(FILE *f, cmph_t *mphf);
15 int chm_dump(cmph_t *mphf, FILE *f);
16 void chm_destroy(cmph_t *mphf);
17 cmph_uint32 chm_search(cmph_t *mphf, const char *key, cmph_uint32 keylen);
18
19 /** \fn void chm_pack(cmph_t *mphf, void *packed_mphf);
20  *  \brief Support the ability to pack a perfect hash function into a preallocated contiguous memory space pointed by packed_mphf.
21  *  \param mphf pointer to the resulting mphf
22  *  \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() 
23  */
24 void chm_pack(cmph_t *mphf, void *packed_mphf);
25
26 /** \fn cmph_uint32 chm_packed_size(cmph_t *mphf);
27  *  \brief Return the amount of space needed to pack mphf.
28  *  \param mphf pointer to a mphf
29  *  \return the size of the packed function or zero for failures
30  */ 
31 cmph_uint32 chm_packed_size(cmph_t *mphf);
32
33 /** cmph_uint32 chm_search(void *packed_mphf, const char *key, cmph_uint32 keylen);
34  *  \brief Use the packed mphf to do a search. 
35  *  \param  packed_mphf pointer to the packed mphf
36  *  \param key key to be hashed
37  *  \param keylen key legth in bytes
38  *  \return The mphf value
39  */
40 cmph_uint32 chm_search_packed(void *packed_mphf, const char *key, cmph_uint32 keylen);
41
42 #endif