Make your own free website on Tripod.com

tree.e 1.0 by Jeffrey Fielding

This include file contains routines for storing and manipulating trees. All trees start at ROOT_NODE. ROOT_NODE is just a place holder, however, and does not have any data or list of children. All nodes except ROOT_NODE have data, a parent, and a list of children. A node is represented by the tree_node type, which is an index into the internal node sequence. It does allow ROOT_NODE, but not any invalid indices. Each node can have only one parent.

node = alloc_node(parent)

Creates a new node with the specified parent and returns its id.

free_node(node)

Removes the node. Its id is now invalid, though it may be re-used by the allocator. Its children are also freed, and its id is removed from its parent's list of children.

own_node(parent, node)

Assigns node to parent. Automatically removes node from it's current parent's list of children, adds it to the new parent's list, and updates the node's parent field.

parent = parent_node(node)

Returns the id of the parent of node.

children = node_children(node)

Returns a sequence of the children of node.

node_set(node, data)

Sets the data of node.

data = node_data(node)

Returns the data associated with node.

Prev: The Tokenizer

Table of Contents