MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_avl_traversal

Function lwp_avl_traversal

components/lwp/lwp_avl.c:237–267  ·  view source on GitHub ↗

* @brief Recursively traverses an AVL tree and applies a function to each node * * @param[in] ptree Pointer to the root node of the AVL tree * @param[in] fun Callback function to apply to each node * @param[in,out] arg Additional argument passed to the callback function * * @return int Returns the last result from the callback function (0 if all nodes processed) * * @note This function per

Source from the content-addressed store, hash-verified

235 * if the callback returns a non-zero value.
236 */
237int lwp_avl_traversal(struct lwp_avl_struct *ptree, int (*fun)(struct lwp_avl_struct *, void *), void *arg)
238{
239 int ret;
240
241 if (!ptree)
242 {
243 return 0;
244 }
245 if (ptree->avl_left)
246 {
247 ret = lwp_avl_traversal(ptree->avl_left, fun, arg);
248 if (ret != 0)
249 {
250 return ret;
251 }
252 }
253 ret = (*fun)(ptree, arg);
254 if (ret != 0)
255 {
256 return ret;
257 }
258 if (ptree->avl_right)
259 {
260 ret = lwp_avl_traversal(ptree->avl_right, fun, arg);
261 if (ret != 0)
262 {
263 return ret;
264 }
265 }
266 return ret;
267}
268
269/**
270 * @brief Finds the first (leftmost) node in an AVL tree

Callers 3

lwp_pid_for_eachFunction · 0.85
lwp_user_object_dupFunction · 0.85
list_shmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected