Buy GNU books!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
When binary search trees were introduced in the last chapter, we used indexes into an array to reference items' smaller and larger values. But in C, BSTs are usually constructed using pointers. This is a more general technique, because pointers aren't restricted to references within a single array.
In struct bst_node, bst_link takes the place of smaller, and bst_link takes the place of larger. If, in our array implementation of binary search trees, either of these would have pointed to the sentinel, it instead is assigned NULL, the null pointer constant.
In addition, bst_data replaces value. We use a void * generic pointer here, instead of int as used in the last chapter, to let any kind of data be stored in the BST. See section 3.3 Comparison Function, for more information on void * pointers.
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|