103 void *data, uint64_t size,
105 int (*cmp)(
const cr8r_base_ft*,
const void*,
const void*),
208 uint64_t a = 0, b = 0;
211 b = (cur -
self->table_b)/ft->
base.
size;
212 if(b++ >= self->len_b){
216 for(; b <
self->len_b; ++b){
217 if((self->flags_b[b >> 5] >> (b&0x1F))&0x100000000ULL){
218 return self->table_b + b*ft->
base.
size;
224 a = (cur -
self->table_a)/ft->
base.
size;
225 if(a++ >= self->len_a){
230 for(; a <
self->len_a; ++a){
231 if((self->flags_a[a >> 5] >> (a&0x1F))&0x100000000ULL){
232 return self->table_a + a*ft->
base.
size;
void * cr8r_hash_append(cr8r_hashtbl_t *, cr8r_hashtbl_ft *, void *key, int *status)
Insert an element into the hash table or modify its value.
int cr8r_hash_remove(cr8r_hashtbl_t *, cr8r_hashtbl_ft *, const void *key)
Remove the element with a given key.
bool cr8r_hash_ft_init(cr8r_hashtbl_ft *, void *data, uint64_t size, uint64_t(*hash)(const cr8r_base_ft *, const void *), int(*cmp)(const cr8r_base_ft *, const void *, const void *), int(*add)(cr8r_base_ft *, void *, void *), void(*del)(cr8r_base_ft *, void *))
Convenience function to initialize a cr8r_hashtbl_ft.
void * cr8r_hash_insert(cr8r_hashtbl_t *, const cr8r_hashtbl_ft *, const void *key, int *status)
Insert an element into the hash table.
const uint64_t cr8r_hash_u64_prime
arbitrary large prime
cr8r_hashtbl_ft cr8r_htft_cstr_u64
function table for using hash table as map from c strings to uint64_t's
void cr8r_hash_destroy(cr8r_hashtbl_t *, cr8r_hashtbl_ft *)
Free the resources held by the hashtable.
void * cr8r_hash_get(cr8r_hashtbl_t *, const cr8r_hashtbl_ft *, const void *key)
Get a pointer to an entry in the hash table.
cr8r_hashtbl_ft cr8r_htft_u64_u64
function table for using hash table as map rom uint64_t's to uint64_t's
void cr8r_hash_clear(cr8r_hashtbl_t *, cr8r_hashtbl_ft *)
Remove all entries from the hash table.
int cr8r_hash_init(cr8r_hashtbl_t *, const cr8r_hashtbl_ft *, uint64_t reserve)
Initialize a hash table.
void cr8r_hash_delete(cr8r_hashtbl_t *, cr8r_hashtbl_ft *, void *ent)
Remove an element of the hash table by pointer.
cr8r_hashtbl_ft cr8r_htft_u64_void
function table for using hash table as set of uint64_t's
Base function table for all Crater containers.
uint64_t size
how large each element is, in bytes
Function table for hash table.
double load_factor
Maximum allowable ratio of entries present to total capacity.
cr8r_base_ft base
Base function table values (data and size)
void * table_a
Buffer for the main internal table.
uint64_t * flags_b
Metadata about which entries are present/deleted/absent in the second table.
uint64_t len_b
Length of buffer for second internal table (in elements not bytes).
uint64_t i
Current index for incremental rehashing.
void * table_b
Buffer for the second internal table if present.
uint64_t full
Total number of elements currently in the table.
uint64_t * flags_a
Metadata about which entries are present/deleted/absent in the main table.
uint64_t len_a
Length of buffer for main internal table (in elements not bytes).
uint64_t r
Amount of entries that are rehashed at once.
uint64_t cap
Total number of elements that can be stored before expanding the table.
entry type for cstr -> uint64_t mapping