Skip to content
Snippets Groups Projects
Commit a2f20cc3 authored by Alec's avatar Alec
Browse files

encore des bugfix...

parent 8aa0e400
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,7 @@ node *bp_split(node *nd) {
// childs for leaves
for (int i = 0; i < upto; i++) {
new->data[i] = nd->data[index + i];
new->user[i] = nd->user[index + i];
nd->data[index + i] = 0;
}
......@@ -285,9 +286,8 @@ node *bp_insert_val(node *tree, entry person) {
// SEARCH ----------------------------------------------------------
entry bp_search_node(node *tree, uint64_t hash) {
if (tree == NULL) {
if (tree == NULL)
return CONST_ENTR;
}
if (bp_is_leaf(tree)) {
for (int i = 0; i < M; i++) {
......@@ -295,11 +295,12 @@ entry bp_search_node(node *tree, uint64_t hash) {
return tree->user[i];
}
} else {
for (int i = 0; i <= M; i++) {
if (tree->data[i] > hash) {
for (int i = 0; i < M; i++) {
if (tree->data[i] > hash || tree->data[i] == 0) {
return bp_search_node(tree->childs[i], hash);
}
}
return bp_search_node(tree->childs[M], hash);
}
return CONST_ENTR;
}
......@@ -400,7 +401,7 @@ void bp_print_as_ll(node *root) {
return bp_print_as_ll(root->childs[0]);
}
printf("|");
printf("| ");
// print every values in the node until hitting 0, then we can get on the
// next node
for (int i = 0; i < M; i++) {
......
......@@ -33,15 +33,15 @@ int main() {
tree = bp_insert_val(tree, person);
strcpy(person.f_name, "Vincent\0");
strcpy(person.l_name, "\0");
strcpy(person.l_name, "Steinmann\0");
strcpy(person.phone, "0795787730\0");
test.day = 24;
test.month = 5;
test.year = 101;
test.year = 97;
person.birth = test;
tree = bp_insert_val(tree, person);
char phone_search[11] = {"0788909566"};
char phone_search[11] = {"0795787730"};
bp_print(tree, 0);
printf("\n|||||||||\n");
printf("Recherche par n° de téléphone : \n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment