1
0
Fork 0

Update tree docs

This commit is contained in:
wael 2021-09-22 11:50:23 +03:00
parent 11d080445c
commit 499c9cb5bb
2 changed files with 15 additions and 2 deletions

View File

@ -5,7 +5,7 @@
# Prompt user at the start for what type they want.
# Specify the file paths, in the order where they should be built.
filepaths=('nodes/single_node.h.ms' 'nodes/double_node.h.ms' 'nodes/tree_node.h.ms' 'strings/strzcpy.ms' 'stack/stack.h.ms' 'linked_lists/double_linked_list.h.ms' 'linked_lists/single_linked_list.h.ms' 'utils/time_function.h.ms')
filepaths=('nodes/single_node.h.ms' 'nodes/double_node.h.ms' 'nodes/tree_node.h.ms' 'strings/strzcpy.ms' 'stack/stack.h.ms' 'linked_lists/double_linked_list.h.ms' 'linked_lists/single_linked_list.h.ms' 'utils/time_function.h.ms' 'trees/binary_tree/binary_tree.h.ms')
# Prompt the user for the option they want (pdf/html/utf8).
echo "Please choose an output option: pdf, html or utf8."

View File

@ -23,6 +23,9 @@ has the fields
.I "data" ,
the former of which are other node pointers, and the latter is a void pointer.
.PP
This header defines a special "max" macro, which takes two variables (a and b), checks that they have maching types, and returns the maximal value between them.
.PP
This header defines the following functions:
.br
@ -30,4 +33,14 @@ tree_node_t* initialize_tree_node(): This function initializes an empty tree nod
.br
tree_node_t* initialize_tree_node_store(void *data): This function initializes an empty tree node, returning the pointer thereof on success and NULL on failure - stores the given data into the node too.
.br
int link_tree_node
int link_tree_node_right(tree_node_t *parent, tree_node_t *child): This function links the child node to the right of its parent, will happily overwrite linked nodes!
.br
int link_tree_node_left(tree_node_t *parent, tree_node_t *child): This function links the child node to the left of its parent, will happily overwrite linked nodes!
.br
void free_tree(tree_node_t *root): This function frees a tree from the given node onwards (including all children thereof but not parentally), will not free stored data.
.br
void free_tree_data(tree_node_t *root, void (*free_function)(const void*)): This function frees a tree from the given node onwards (including all children thereof but not parentally), will also free stored data - if free_function is not NULL, it'll be used to free said data, otherwise will use stdlib's free().
.br
int insert_into_tree(tree_node_t *root, tree_node_t *to_insert, int (*comparison_function)(const void*, const void*)): This function attempts to automatically insert a node into a given tree (if any are NULL, will return an error), if comparison_function is NULL - will use standard < comparison instead.
.br
size_t find_tree_depth(tree_node_t *root): Finds the tree's depth at the given root.