-
Notifications
You must be signed in to change notification settings - Fork 0
/
btree_getitem.c
executable file
·28 lines (26 loc) · 1.22 KB
/
btree_getitem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_getitem.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/26 20:42:34 by akharrou #+# #+# */
/* Updated: 2019/03/04 13:17:20 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/btree.h"
void *btree_getitem(t_btree *root, void *item_ref,
int (*cmpf)(void *, void *))
{
if (root)
{
if ((*cmpf)(root->item, item_ref) == 0)
return (root->item);
if (root->left)
return (btree_getitem(root->left, item_ref, cmpf));
if (root->right)
return (btree_getitem(root->right, item_ref, cmpf));
}
return (0);
}