diff options
author | Colin Walters <walters@verbum.org> | 2010-11-11 15:01:07 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-12-03 16:03:31 -0500 |
commit | 3a94a5e36287072486831eb68bfe43a0e1c8ea78 (patch) | |
tree | 59eb83ba02a9acfd7032c2199d6e523e89efe418 /girepository/cmph/compressed_rank.h | |
parent | f6e5defff5a8d8ba83e0b414496d28b5e2361f39 (diff) | |
download | gobject-introspection-3a94a5e36287072486831eb68bfe43a0e1c8ea78.tar.gz |
Import CMPH 1.0
This will be used for typelib indexing. See README-CMPH-IMPORT.txt
for more information.
Diffstat (limited to 'girepository/cmph/compressed_rank.h')
-rw-r--r-- | girepository/cmph/compressed_rank.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/girepository/cmph/compressed_rank.h b/girepository/cmph/compressed_rank.h new file mode 100644 index 00000000..bfe930dd --- /dev/null +++ b/girepository/cmph/compressed_rank.h @@ -0,0 +1,55 @@ +#ifndef __CMPH_COMPRESSED_RANK_H__ +#define __CMPH_COMPRESSED_RANK_H__ + +#include "select.h" + +struct _compressed_rank_t +{ + cmph_uint32 max_val; + cmph_uint32 n; // number of values stored in vals_rems + // The length in bits of each value is decomposed into two compnents: the lg(n) MSBs are stored in rank_select data structure + // the remaining LSBs are stored in a table of n cells, each one of rem_r bits. + cmph_uint32 rem_r; + select_t sel; + cmph_uint32 * vals_rems; +}; + +typedef struct _compressed_rank_t compressed_rank_t; + +void compressed_rank_init(compressed_rank_t * cr); + +void compressed_rank_destroy(compressed_rank_t * cr); + +void compressed_rank_generate(compressed_rank_t * cr, cmph_uint32 * vals_table, cmph_uint32 n); + +cmph_uint32 compressed_rank_query(compressed_rank_t * cr, cmph_uint32 idx); + +cmph_uint32 compressed_rank_get_space_usage(compressed_rank_t * cr); + +void compressed_rank_dump(compressed_rank_t * cr, char **buf, cmph_uint32 *buflen); + +void compressed_rank_load(compressed_rank_t * cr, const char *buf, cmph_uint32 buflen); + + +/** \fn void compressed_rank_pack(compressed_rank_t *cr, void *cr_packed); + * \brief Support the ability to pack a compressed_rank structure into a preallocated contiguous memory space pointed by cr_packed. + * \param cr points to the compressed_rank structure + * \param cr_packed pointer to the contiguous memory area used to store the compressed_rank structure. The size of cr_packed must be at least @see compressed_rank_packed_size + */ +void compressed_rank_pack(compressed_rank_t *cr, void *cr_packed); + +/** \fn cmph_uint32 compressed_rank_packed_size(compressed_rank_t *cr); + * \brief Return the amount of space needed to pack a compressed_rank structure. + * \return the size of the packed compressed_rank structure or zero for failures + */ +cmph_uint32 compressed_rank_packed_size(compressed_rank_t *cr); + + +/** \fn cmph_uint32 compressed_rank_query_packed(void * cr_packed, cmph_uint32 idx); + * \param cr_packed is a pointer to a contiguous memory area + * \param idx is an index to compute the rank + * \return an integer that represents the compressed_rank value. + */ +cmph_uint32 compressed_rank_query_packed(void * cr_packed, cmph_uint32 idx); + +#endif |