Example #1
0
void	*ft_btree_search_item(t_btree **root, void *data_ref,
											int (*cmpf)(void *, void *))
{
	t_btree	*result;

	result = NULL;
	if ((*root)->left)
		if ((result = ft_btree_search_item(&(*root)->left, data_ref, cmpf)))
			return (result);
	if (cmpf(data_ref, (*root)->content) == 0)
		return (*root);
	if ((*root)->right)
		if ((result = ft_btree_search_item(&(*root)->right, data_ref, cmpf)))
			return (result);
	return (NULL);
}
Example #2
0
void	*ft_btree_search_item(t_btree *root, t_ftbuffer *data_ref,
			int (*cmpf)(t_ftbuffer *, t_ftbuffer *))
{
	if (root && cmpf && data_ref)
	{
		if (!(*cmpf)(data_ref, root->data))
			return (root);
		else
		{
			if (root->left)
				return (ft_btree_search_item(root->left, data_ref, cmpf));
			if (root->right)
				return (ft_btree_search_item(root->left, data_ref, cmpf));
		}
	}
	return (NULL);
}