30 lines
1.2 KiB
C
30 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* btree_create_node.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */
|
|
/* Updated: 2016/08/23 19:04:56 by jhalford ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "ft_btree.h"
|
|
|
|
void *btree_search_item(t_btree *root,
|
|
void *data_ref, int (*cmpf)(void *, void *))
|
|
{
|
|
void *out;
|
|
|
|
out = NULL;
|
|
if (root)
|
|
{
|
|
out = btree_search_item(root->left, data_ref, cmpf);
|
|
if (!out && ((*cmpf)(root->item, data_ref) == 0))
|
|
out = root->item;
|
|
if (!out)
|
|
out = btree_search_item(root->right, data_ref, cmpf);
|
|
}
|
|
return (out);
|
|
}
|