aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-29 15:57:38 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-29 15:57:38 +0300
commitef0a23b0636a8c7f4a3c802ff76645261e8b225f (patch)
tree89234edc2bd60b1e7907857057eaa7d6bcc386e2 /src
parent7b0eaa806f2cfc84e4c26f8f608e1d4e4843ea05 (diff)
downloadrevela-ef0a23b0636a8c7f4a3c802ff76645261e8b225f.tar.gz
revela-ef0a23b0636a8c7f4a3c802ff76645261e8b225f.zip
bst: fix predecessor and successor funcs
Diffstat (limited to 'src')
-rw-r--r--src/bstree.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/bstree.c b/src/bstree.c
index f0312a8..7d4f14f 100644
--- a/src/bstree.c
+++ b/src/bstree.c
@@ -107,13 +107,13 @@ bstree_min(struct bstnode *node)
struct bstnode *
bstree_successor(struct bstnode *na)
{
- bstree_xcessor(na, right, max);
+ bstree_xcessor(na, right, min);
}
struct bstnode *
bstree_predecessor(struct bstnode *na)
{
- bstree_xcessor(na, left, min);
+ bstree_xcessor(na, left, max);
}
bool
@@ -124,7 +124,7 @@ bstree_inorder_walk(struct bstnode *node, bst_walk_cb cb, void *data)
}
if (!cb(node, data)) return false;
if (node->right != NULL) {
- if (!bstree_inorder_walk(node->right, cb, data)) return false;
+ return bstree_inorder_walk(node->right, cb, data);
}
return true;
}