diff --git a/bp_tree.c b/bp_tree.c index d562e9e03b4dbf7c59bf9a3dda0d122d5f743759..97fa2ef668ca3f73019be0815a3f25f8f343aa8d 100644 --- a/bp_tree.c +++ b/bp_tree.c @@ -329,6 +329,25 @@ void bp_destroy(node *root) { // PRINTING ---------------------------------------------------------- +void bp_print_everything(node *tree) { // if we reached the end of the list + if (tree == NULL) + return; + + // search for the first leaf on the tree + if (!bp_is_leaf(tree)) { + return bp_print_everything(tree->childs[0]); + } + // print every values in the node until hitting 0, then we can get on the + // next node + for (int i = 0; i < M; i++) { + bp_print_entry(tree->user[i]); + printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + if (tree->data[i + 1] == 0) { + return bp_print_everything(tree->next); + } + } +} + void print_date(date item) { printf("%d - ", item.day); diff --git a/bp_tree.h b/bp_tree.h index f04e9b97c953b95f919b44d39f9b38364a70f305..b33052fecddf4a1ad2368c716895df4d2b4fbd23 100644 --- a/bp_tree.h +++ b/bp_tree.h @@ -39,6 +39,8 @@ void bp_print(node *root, int depth); void bp_print_entry(entry person); +void bp_print_everything(node *tree); + void bp_search(node *tree, char phone[11]); /** diff --git a/main.c b/main.c index 8fe32eccf8aaa40f2a8397a78a7c53e27b72a5ca..89374afcf87bf78dbba2f4b4031fa455de5af897 100644 --- a/main.c +++ b/main.c @@ -44,8 +44,9 @@ int main() { char phone_search[11] = {"0795787730"}; bp_print(tree, 0); printf("\n|||||||||\n"); - printf("Recherche par n° de téléphone : \n"); + bp_print_everything(tree); + printf("\nRecherche par n° de téléphone : \n"); bp_search(tree, phone_search); /*