-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGtree.h
69 lines (67 loc) · 2.56 KB
/
Gtree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct StBinTree * PbinTree;
/**
* @brief { Prints the binary tree using pre-order algorithm. }
*
* @param[in] pBinTree { Binary tree control pointer. }
**/
void list_pre_order(PbinTree);
/**
* @brief { Prints the binary tree using pos-order algorithm }
*
* @param[in] pBinTree { Binary tree control pointer. }
*/
void list_pos_order(PbinTree);
/**
* @brief { Prints the binary tree using in-order algorithm }
*
* @param[in] pBinTree { Binary tree control pointer. }
*/
void list_in_order(PbinTree);
/**
* @brief Gets an element in binary tree. It uses the compare function passed while
* initiating the structure to get the element.
*
* @param[in] pBinTree { Binary tree control pointer. }
* @param searchElement { Void* pointer to element that we want to search. }
* @param retrievedElement { Void* data to the retrieved information. }
* @return 0 -> Success.
* 1 -> Not found.
*/
int get_element(PbinTree,void*,void*);
/**
* @brief Deletes an element in binary tree. It uses the compare function passed while
* initiating the structure to remove the element.
*
* @param[in] pBinTree { Binary tree control pointer. }
* @param deleteElement { Void* pointer to element that we want to delete. }
* @return 0 -> Success.
* 1 -> Not found.
*/
int delete_element(PbinTree, void*);
/**
* @brief { Function that allow us to insert generic data. }
*
* @param[in] pBinTree { Binary tree control pointer. }
* @param insertElement { Void* pointer to element that we want to insert. }
*
* @return 0 -> Success.
* 1 -> Malloc failed. Probably not enough memory.
*/
int insert(PbinTree ctrl, void* data);
/**
* @brief Initializes the generic binary tree.
*
* @param pBinTree { Binary tree control pointer. }
* @param[in] size_t { Generic data size. (sizeof(StructMyData)) }
* @param[in] compare { Pointer to the compare function. Its used in insert, delete and get element.This function dictates the order in binary tree. }
* @param get_key { Pointer to the get_key function, that allow us to know the unique key. }
* @param to_string { Pointer to the to_string function. It allow us to creating a char* with all the infos that we need.
* Its used in pre,pos,in order methods }
*
* @return 0 -> Success.
* 1 -> Malloc failed. Probably not enough memory.
*/
int init_g_tree(PbinTree*,size_t, int (*) (void*,void*),char* (*) (void*), char* (*) (void*));