* @brief Finds a node in an AVL tree by key * * @param[in] key The key to search for in the AVL tree * @param[in] ptree Pointer to the root node of the AVL tree * * @return struct lwp_avl_struct* Pointer to the found node, or NULL if not found * * @note This function searches the AVL tree for a node with the specified key. * It performs a standard binary search by comparing keys and
| 204 | * left or right subtrees accordingly. |
| 205 | */ |
| 206 | struct lwp_avl_struct *lwp_avl_find(avl_key_t key, struct lwp_avl_struct *ptree) |
| 207 | { |
| 208 | for (;;) |
| 209 | { |
| 210 | if (ptree == AVL_EMPTY) |
| 211 | { |
| 212 | return (struct lwp_avl_struct *)0; |
| 213 | } |
| 214 | if (key == ptree->avl_key) |
| 215 | break; |
| 216 | if (key < ptree->avl_key) |
| 217 | ptree = ptree->avl_left; |
| 218 | else |
| 219 | ptree = ptree->avl_right; |
| 220 | } |
| 221 | return ptree; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * @brief Recursively traverses an AVL tree and applies a function to each node |
no outgoing calls
no test coverage detected