| www.delorie.com/gnu/docs/avl/libavl_37.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The struct bst_table structure ties together all of the data needed to keep track of a table implemented as a binary search tree:
Most of struct bst_table's members should be familiar. Member bst_root points to the root node of the BST. Together, bst_compare and bst_param specify how items are compared (see section 3.4 Item and Copy Functions). The members of bst_alloc specify how to allocate memory for the BST (see section 3.5 Memory Allocation). The number of items in the BST is stored in bst_count (see section 3.7 Count).
The final member, bst_generation, is a generation number. When a tree is created, it starts out at zero. After that, it is incremented every time the tree is modified in a way that might disturb a traverser. We'll talk more about the generation number later (see section 5.9.3 Better Iterative Traversal).
Exercises:
*1. Why is it a good idea to include bst_count in struct bst_table? Under what circumstances would it be better to omit it? [answer]
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |