Search / Sort
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#ifndef INCLUDED_C_SEPARATECHAININGHASHST_H
|
||||
#define INCLUDED_C_SEPARATECHAININGHASHST_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
#ifndef INCLUDED_C_SEQSEARCHST_H
|
||||
#include <c_SeqSearchST.h>
|
||||
#endif /*INCLUDED_C_SEQSEARCHST_H*/
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
|
||||
typedef struct {
|
||||
c_size_t m_buckets; // 哈希表内的桶(拉链数量)总基数 (M)
|
||||
c_size_t size; // 当前整个哈希映射表内有效驻留的键值对总数 (N)
|
||||
c_SeqSearchST_t* buckets; // 密集排布的拉链桶符号表动态数组:buckets[0 ... M-1]
|
||||
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_SeparateChainingHashST_t;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_SeparateChainingHashST_Init(c_SeparateChainingHashST_t* self, c_size_t initial_buckets,
|
||||
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_SeparateChainingHashST_Put(c_SeparateChainingHashST_t* self, const void* key, const void* val);
|
||||
|
||||
c_err_t c_SeparateChainingHashST_Get(const c_SeparateChainingHashST_t* self, const void* key, void* out_val);
|
||||
|
||||
bool c_SeparateChainingHashST_Contains(const c_SeparateChainingHashST_t* self, const void* key);
|
||||
|
||||
c_err_t c_SeparateChainingHashST_Delete(c_SeparateChainingHashST_t* self, const void* key);
|
||||
|
||||
void c_SeparateChainingHashST_Destroy(c_SeparateChainingHashST_t* self);
|
||||
|
||||
#endif /*INCLUDED_C_SEPARATECHAININGHASHST_H*/
|
||||
Reference in New Issue
Block a user