42/d13/ex04/btree_insert_data.c
2016-11-20 02:20:23 +02:00

28 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_insert_data.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/11 19:17:19 by gtertysh #+# #+# */
/* Updated: 2016/11/11 21:21:32 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "ft_btree.h"
void btree_insert_data(t_btree **root, void *item,
int (*cmpf)(void *, void *))
{
if (*root == NULL)
{
*root = btree_create_node(item);
return ;
}
if (cmpf(item, (*root)->item) >= 0)
btree_insert_data(&(*root)->right, item, cmpf);
else if (cmpf(item, (*root)->item) < 0)
btree_insert_data(&(*root)->left, item, cmpf);
}