# HG changeset patch # User Mike Becker # Date 1707943412 -3600 # Node ID f4faa7f73cb8db2ec8cb9bf0733d1ed6d75b9d7b # Parent e2243453127fe109b6e42430eb649819438e34ba declare cx_tree_search_func function pointer diff -r e2243453127f -r f4faa7f73cb8 src/cx/tree.h --- 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