Search / Sort
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef INCLUDED_C_BINARYSEARCHST_H
|
||||
#define INCLUDED_C_BINARYSEARCHST_H
|
||||
|
||||
|
||||
#ifndef INCLUDED_C_SORTCOMPARE_H
|
||||
#include <c_SortCompare.h>
|
||||
#endif /*INCLUDED_C_SORTCOMPARE_H*/
|
||||
|
||||
#ifndef INCLUDED_C_ALLOCATOR_H
|
||||
#include <c_Allocator.h>
|
||||
#endif /*INCLUDED_C_ALLOCATOR_H*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
char* keys; // 密集排布的有序键数组载体 (保持严格升序排列)
|
||||
char* vals; // 与键数组物理下标一一对应的值数组载体
|
||||
c_size_t capacity; // 当前容器的最大可容纳插槽数
|
||||
c_size_t size; // 当前已存储的有效键值对总个数
|
||||
c_size_t key_size; // 单个键对象占用的物理字节大小 (sizeof)
|
||||
c_size_t val_size; // 单个值对象占用的物理字节大小 (sizeof)
|
||||
c_SortCompare_t cmp; // 键对象专用的动态回调比对器
|
||||
void* args; // 自定义上下文参数指针
|
||||
c_Allocator_t allocator;// 内联组合分配器实例与默认 Fallback 缺省机制
|
||||
} c_BinarySearchST_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_BinarySearchST_Init(c_BinarySearchST_t* self, c_size_t initial_capacity, c_size_t key_size, c_size_t val_size, c_SortCompare_t cmp, void* args, c_Allocator_t* allocator);
|
||||
|
||||
c_err_t c_BinarySearchST_Get(const c_BinarySearchST_t* self, const void* key, void* out_val);
|
||||
|
||||
bool c_BinarySearchST_Contains(const c_BinarySearchST_t* self, const void* key);
|
||||
|
||||
c_err_t c_BinarySearchST_Put(c_BinarySearchST_t* self, const void* key, const void* val);
|
||||
|
||||
c_err_t c_BinarySearchST_Delete(c_BinarySearchST_t* self, const void* key);
|
||||
|
||||
void c_BinarySearchST_Destroy(c_BinarySearchST_t* self);
|
||||
|
||||
#endif /*INCLUDED_C_BINARYSEARCHST_H*/
|
||||
Reference in New Issue
Block a user