#ifndef INCLUDED_C_BINARYSEARCHST_H #define INCLUDED_C_BINARYSEARCHST_H #ifndef INCLUDED_C_BASE_H #include #endif /*INCLUDED_C_BASE_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*/