#ifndef INCLUDED_C_BST_H #define INCLUDED_C_BST_H #ifndef INCLUDED_C_TYPES_H #include #endif /*INCLUDED_C_TYPES_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ // Forward declaration of internal node structure typedef struct c_BSTNode { struct c_BSTNode* left; // Pointer to left child struct c_BSTNode* right; // Pointer to right child // Node payload layout: key block followed immediately by the value block in memory } c_BSTNode_t; // Binary Search Tree Context Structure typedef struct { c_BSTNode_t* root; // Root node pointer c_size_t key_size; // Size of each key in bytes c_size_t val_size; // Size of each value in bytes c_size_t size; // Total number of nodes in the tree int (*compar)(const void*, const void*); // Key comparison rule pointer } c_BST_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_err_t c_BST_Init(c_BST_t* tree, c_size_t key_size, c_size_t val_size, int (*compar)(const void*, const void*)) ; void c_BST_Destroy(c_BST_t* tree); c_err_t c_BST_Clear(c_BST_t* tree); c_bool_t c_BST_Contains(const c_BST_t* tree, const void* key); c_err_t c_BST_Put(c_BST_t* tree, const void* key, const void* val); void* c_BST_Get(const c_BST_t* tree, const void* key); c_err_t c_BST_Delete(c_BST_t* tree, const void* key) ; #endif /*INCLUDED_C_BST_H*/