Skip to content

Commit

Permalink
Khởi tạo tiến trình duyệt với cây rỗng
Browse files Browse the repository at this point in the history
  • Loading branch information
bangoc committed Dec 30, 2023
1 parent 6908290 commit 5f493ca
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions cont/tmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,27 +452,18 @@ struct TNN(tname) *TNN(tname)(ktype key, vtype value) { \
return nn; \
} \
struct TNN(tname) *prefix##left_most(struct TNN(tname) *n) { \
if (!n) { \
return NULL; \
} \
while (n->left) { \
n = n->left; \
} \
return n; \
} \
struct TNN(tname) *prefix##right_most(struct TNN(tname) *n) { \
if (!n) { \
return NULL; \
} \
while (n->right) { \
n = n->right; \
} \
return n; \
} \
struct TNN(tname) *prefix##left_deepest(struct TNN(tname) *n) { \
if (!n) { \
return NULL; \
} \
for (;;) { \
if (n->left) { \
n = n->left; \
Expand Down Expand Up @@ -514,13 +505,13 @@ struct TNN(tname) *prefix##prev_lnr(struct TNN(tname) *n) { \
return top; \
} \
struct TNN(tname) *prefix##first_lrn(struct tname *t) { \
return prefix##left_deepest(t->root); \
return t->root? prefix##left_deepest(t->root): NULL; \
} \
struct TNN(tname) *prefix##first_lnr(struct tname *t) { \
return prefix##left_most(t->root); \
return t->root? prefix##left_most(t->root): NULL; \
} \
struct TNN(tname) *prefix##last_lnr(struct tname *t) { \
return prefix##right_most(t->root); \
return t->root? prefix##right_most(t->root): NULL; \
} \
struct TNN(tname) *prefix##pval_node(void *pv) { \
return pv? pv - offsetof(struct TNN(tname), value): NULL; \
Expand Down

0 comments on commit 5f493ca

Please sign in to comment.