#ifndef INCLUDED_C_LINEARPROBINGHASHST_H #define INCLUDED_C_LINEARPROBINGHASHST_H #ifndef INCLUDED_C_TYPES_H #include #endif /*INCLUDED_C_TYPES_H*/ #ifndef INCLUDED_C_SORTCOMPARE_H #include #endif /*INCLUDED_C_SORTCOMPARE_H*/ #ifndef INCLUDED_C_ALLOCATOR_H #include #endif /*INCLUDED_C_ALLOCATOR_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { char* keys; // 密集排布的键连续字节数组载体 char* vals; // 与键数组物理下标一一对应的值连续字节数组载体 bool* occupied; // 标志位布尔数组:occupied[i] 为 true 代表该插槽当前已存入有效数据 c_size_t m_capacity; // 当前哈希表大连续数组的物理插槽总容量 (M) c_size_t size; // 当前哈希表内实际驻留的有效键值对总个数 (N) c_size_t key_size; // 单个键对象占用的物理字节大小 (sizeof) c_size_t val_size; // 单个值对象占用的物理字节大小 (sizeof) c_SortCompare_t key_cmp;// 键对象专用的全等回调比对器 void* args; // 自定义上下文参数指针 c_Allocator_t allocator;// 内联组合分配器实例与自适应 Fallback 缺省 } c_LinearProbingHashST_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_err_t c_LinearProbingHashST_Init(c_LinearProbingHashST_t* self, c_size_t initial_capacity, c_size_t key_size, c_size_t val_size, c_SortCompare_t key_cmp, void* args, c_Allocator_t* allocator); c_err_t c_LinearProbingHashST_Resize(c_LinearProbingHashST_t* self, c_size_t new_capacity); c_err_t c_LinearProbingHashST_Put(c_LinearProbingHashST_t* self, const void* key, const void* val); c_err_t c_LinearProbingHashST_Get(const c_LinearProbingHashST_t* self, const void* key, void* out_val); bool c_LinearProbingHashST_Contains(const c_LinearProbingHashST_t* self, const void* key); c_err_t c_LinearProbingHashST_Delete(c_LinearProbingHashST_t* self, const void* key); void c_LinearProbingHashST_Destroy(c_LinearProbingHashST_t* self); #endif /*INCLUDED_C_LINEARPROBINGHASHST_H*/