61 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION) 62 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead." 65 #ifndef PLIBSYS_HEADER_PTREE_H 66 #define PLIBSYS_HEADER_PTREE_H P_LIB_API PTree * p_tree_new_full(PTreeType type, PCompareDataFunc func, ppointer data, PDestroyFunc key_destroy, PDestroyFunc value_destroy)
Initializes new PTree with additional data and memory management.
P_LIB_API ppointer p_tree_lookup(PTree *tree, pconstpointer key)
Lookups a value by a given key.
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Red-black self-balancing tree.
void(* PDestroyFunc)(ppointer data)
Object destroy notification function.
P_LIB_API PTreeType p_tree_get_type(const PTree *tree)
Gets a tree algorithm type.
P_LIB_API PTree * p_tree_new(PTreeType type, PCompareFunc func)
Initializes new PTree.
P_LIB_API PTree * p_tree_new_with_data(PTreeType type, PCompareDataFunc func, ppointer data)
Initializes new PTree with additional data.
pint(* PCompareFunc)(pconstpointer a, pconstpointer b)
Compares two values.
pint(* PCompareDataFunc)(pconstpointer a, pconstpointer b, ppointer data)
Compares two values with additional data.
void * ppointer
Type for a pointer.
const void * pconstpointer
Type for a const pointer.
signed int pboolean
Type for a bool.
P_LIB_API void p_tree_insert(PTree *tree, ppointer key, ppointer value)
Inserts a new key-value pair into a tree.
pboolean(* PTraverseFunc)(ppointer key, ppointer value, ppointer user_data)
Function to traverse through a key-value container.
struct PTree_ PTree
Tree opaque data structure.
P_LIB_API void p_tree_clear(PTree *tree)
Clears a tree.
P_LIB_API pint p_tree_get_nnodes(const PTree *tree)
Gets node count.
#define P_LIB_API
Exports a symbol from a shared library.
enum PTreeType_ PTreeType
Internal data organization algorithm for PTree.
P_LIB_API pboolean p_tree_remove(PTree *tree, pconstpointer key)
Removes a key from a tree.
PTreeType_
Internal data organization algorithm for PTree.
P_LIB_API void p_tree_free(PTree *tree)
Frees a previously initialized tree object.
P_LIB_API void p_tree_foreach(PTree *tree, PTraverseFunc traverse_func, ppointer user_data)
Iterates in-order through the tree nodes.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.