8.4 Insertion [ToC] [Index]     [Skip Back] [Skip Fwd]     [Prev] [Up] [Next]

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:

303. <TAVL item insertion function 303> =
void **
tavl_probe (struct tavl_table *tree, void *item)
{ <avl_probe() local variables; avl => tavl 149> assert (tree != NULL && item != NULL); <Step 1: Search TAVL tree for insertion point 304> <Step 2: Insert TAVL node 305> <Step 3: Update balance factors after AVL insertion; avl => tavl 152> <Step 4: Rebalance after TAVL insertion 306> }

This code is included in 302.