Wed, 14 Feb 2024 21:43:32 +0100
declare cx_tree_search_func function pointer
src/cx/tree.h | file | annotate | diff | comparison | revisions |
--- a/src/cx/tree.h Wed Feb 14 21:31:38 2024 +0100 +++ b/src/cx/tree.h Wed Feb 14 21:43:32 2024 +0100 @@ -87,6 +87,29 @@ ptrdiff_t loc_next ); +/** + * Function pointer for a search function. + * + * A function of this kind shall check if the specified \p node + * contains the given \p data or if one of the children might contain + * the data. + * + * For example if a tree stores file path information, a node that is + * describing a parent directory of a filename that is searched, shall + * return 1 to indicate that a child node might contain the searched item. + * On the other hand, if the node denotes a path that is not a prefix of + * the searched filename, the function would return -1 to indicate that + * the search does not need to be continued in that branch. + * + * @param node the node that is currently investigated + * @param data the data that is searched for + * + * @return 0 if the node contains the data, + * 1 if one of the children might contain the data, + * -1 if neither the node, nor the children contains the data + */ +int (*cx_tree_search_func)(void const *node, void const* data); + #ifdef __cplusplus } // extern "C" #endif