home support FAQ resources services partners contact us contact us
 Web Application Previous  Next  
 Tutorial

}
function tree_get_left(&$tree_array, $handle)
{
// retrieve node from array
$node = $tree_array[$handle];
// check if node is actually allocated
if($node->free)
// node is not allocated, return error
return(-1);
// node is allocated, return its left child
return($node->left);
}
function tree_get_right(&$tree_array, $handle)
{
continues
62 Chapter 2 Advanced Syntax
// retrieve node from array
$node = $tree_array[$handle];
// check if node is actually allocated
if($node->free)
// node is not allocated, return error
return(-1);
// node is allocated, return its left child
return($node->right);
}
function tree_assign_node_contents(&$tree_array, $handle, $contents)
{
// retrieve node from array
$node = $tree_array[$handle];
// check if node is actually allocated
if($node->free)
// node is not allocated, return error
return(-1);
// assign contents to node
$node->contents = $contents;
// assign node back into array
$tree_array[$handle] = $node;
// return success
return(1);
}
function tree_retrieve_node_contents(&$tree_array, $handle)
{
// retrieve node from array
$node = $tree_array[$handle];
// check if node is actually allocated
if($node->free)
// node is not allocated, return error
return(-1);
// return contents of this node
return($node->contents);
}

Listing 2.2 Continued
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist