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

Function _aspace_bst_insert

examples/test/avl.c:442–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440#endif
441
442void _aspace_bst_insert(struct rt_aspace *aspace, struct rt_varea *varea)
443{
444 struct util_avl_root *root = &aspace->tree.tree;
445 struct util_avl_struct *current = NULL;
446 struct util_avl_struct **next = &(root->root_node);
447 rt_ubase_t key = (rt_ubase_t)varea->start;
448
449 /* Figure out where to put new node */
450 while (*next)
451 {
452 current = *next;
453 struct rt_varea *data = VAREA_ENTRY(current);
454
455 if (key < (rt_ubase_t)data->start)
456 next = &(current->avl_left);
457 else if (key > (rt_ubase_t)data->start)
458 next = &(current->avl_right);
459 else
460 return;
461 }
462
463 /* Add new node and rebalance tree. */
464 _check_bst_before(aspace, varea);
465 util_avl_link(&varea->node.node, current, next);
466 util_avl_rebalance(current, root);
467 _check_bst_after(aspace, varea, 0);
468 return;
469}
470
471void _aspace_bst_remove(struct rt_aspace *aspace, struct rt_varea *varea)
472{

Callers 1

insert_testFunction · 0.70

Calls 4

_check_bst_beforeFunction · 0.85
util_avl_linkFunction · 0.85
util_avl_rebalanceFunction · 0.85
_check_bst_afterFunction · 0.85

Tested by

no test coverage detected