#ifndef INCLUDED_C_LINEARPROBINGHASHST_H #define INCLUDED_C_LINEARPROBINGHASHST_H #ifndef INCLUDED_C_BASE_H #include #endif /*INCLUDED_C_BASE_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ // Linear Probing Hash Symbol Table Instance Layout typedef struct { void* keys; // Flat parallel array block storing keys void* vals; // Flat parallel array block storing values c_bool_t* occupied; // Flag array tracking whether a specific slot is filled c_size_t M; // Linear probing table capacity (array size) c_size_t N; // Current active element count c_size_t key_size; // Size of each key in bytes c_size_t val_size; // Size of each value in bytes uint32_t (*hash_fn)(const void* key, c_size_t key_size); // Hash function int (*key_compar)(const void*, const void*); // Key comparison rule pointer } c_LinearProbingHashST_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_err_t c_LinearProbingHashST_Init(c_LinearProbingHashST_t* st, c_size_t initial_capacity, c_size_t key_size, c_size_t val_size, uint32_t (*hash_fn)(const void*, c_size_t), int (*key_compar)(const void*, const void*)); void c_LinearProbingHashST_Destroy(c_LinearProbingHashST_t* st); c_err_t c_LinearProbingHashST_Put(c_LinearProbingHashST_t* st, const void* key, const void* val); void* c_LinearProbingHashST_Get(const c_LinearProbingHashST_t* st, const void* key); c_bool_t c_LinearProbingHashST_Contains(const c_LinearProbingHashST_t* st, const void* key); c_err_t c_LinearProbingHashST_Delete(c_LinearProbingHashST_t* st, const void* key); #endif /*INCLUDED_C_LINEARPROBINGHASHST_H*/