Search/Sort

This commit is contained in:
2026-08-29 01:58:00 +08:00
parent 8e95904cc4
commit a0758766c5
56 changed files with 5425 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#ifndef INCLUDED_C_BINARYSEARCHST_H
#define INCLUDED_C_BINARYSEARCHST_H
#ifndef INCLUDED_C_TYPES_H
#include <c_Types.h>
#endif /*INCLUDED_C_TYPES_H*/
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
void* keys; // Flat parallel array block storing keys
void* vals; // Flat parallel array block storing values
c_size_t key_size; // Size of each key in bytes (sizeof(Key))
c_size_t val_size; // Size of each value in bytes (sizeof(Value))
c_size_t capacity; // Maximum allocated element capacity
c_size_t size; // Current active entry count
int (*compar)(const void*, const void*); // Key comparison rule pointer
} c_BinarySearchST_t;
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
c_err_t c_BinarySearchST_Init(c_BinarySearchST_t* st, c_size_t initial_capacity,
c_size_t key_size, c_size_t val_size,
int (*compar)(const void*, const void*));
void c_BinarySearchST_Destroy(c_BinarySearchST_t* st);
c_err_t c_BinarySearchST_Clear(c_BinarySearchST_t* st);
c_bool_t c_BinarySearchST_Contains(const c_BinarySearchST_t* st, const void* key);
c_err_t c_BinarySearchST_Put(c_BinarySearchST_t* st, const void* key, const void* val);
void* c_BinarySearchST_Get(const c_BinarySearchST_t* st, const void* key);
c_err_t c_BinarySearchST_Delete(c_BinarySearchST_t* st, const void* key);
#endif /*INCLUDED_C_BINARYSEARCHST_H*/