Skip to content

Commit

Permalink
Hiệu chỉnh rbm_insert: trả về con trỏ tới value thay vì nút trong cây
Browse files Browse the repository at this point in the history
  • Loading branch information
bangoc committed Jan 13, 2022
1 parent bd3814f commit f4548ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef struct rbm_s {
} *rbm_t;

typedef struct rbm_insert_result {
rbm_node_t nd;
gtype *value;
int inserted;
} rbm_ires;

Expand Down
4 changes: 2 additions & 2 deletions src/rbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ rbm_ires rbm_insert(rbm_t t, gtype key, gtype value) {
gtype_cmp_t cmp = t->cmp;
bns_insert_setup(loc, t->t.root, key, tm_cmp_conv, same, parent);
if (same) {
return (rbm_ires){to_rbm(same), 0};
return (rbm_ires){&rbm_node_value(same), 0};
}
rbm_node_t n = rbm_create_node(key, value);
rb_insert((bn_tree_t)t, to_bn(n), loc, parent);
return (rbm_ires){n, 1};
return (rbm_ires){&rbm_node_value(n), 1};
}

rbm_node_t rbm_search(rbm_t t, gtype key) {
Expand Down

0 comments on commit f4548ac

Please sign in to comment.