8.4 Insertion |
Insertion into an AVL tree is not complicated much by the need to update threads. The outline is the same as before, and the code for step 3 and the local variable declarations can be reused entirely:
301. <TAVL item insertion function 301> = void **
tavl_probe (struct tavl_table *tree, void *item)
{ <avl_probe() local variables; avl => tavl 147> assert (tree != NULL && item != NULL); <Step 1: Search TAVL tree for insertion point 302> <Step 2: Insert TAVL node 303> <Step 3: Update balance factors after AVL insertion; avl => tavl 150> <Step 4: Rebalance after TAVL insertion 304> }
This code is included in 300.