fix: lstdel && feat: del red black tree
This commit is contained in:
parent
e846b98fcd
commit
cf6bb62030
12
ft_lstdel.c
12
ft_lstdel.c
|
@ -6,7 +6,7 @@
|
||||||
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2015/11/30 21:34:50 by gbrochar #+# #+# */
|
/* Created: 2015/11/30 21:34:50 by gbrochar #+# #+# */
|
||||||
/* Updated: 2015/12/05 15:10:37 by gbrochar ### ########.fr */
|
/* Updated: 2024/10/25 14:32:43 by gbrochar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
|
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
|
||||||
{
|
{
|
||||||
t_list *tmp;
|
if (*alst)
|
||||||
|
|
||||||
while (*alst)
|
|
||||||
{
|
{
|
||||||
tmp = *alst;
|
ft_lstdel(&(*alst)->next, del);
|
||||||
ft_lstdelone(alst, del);
|
del((*alst)->content, (*alst)->content_size);
|
||||||
*alst = tmp->next;
|
ft_memdel((void **)alst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
ft_rb_tree.c
11
ft_rb_tree.c
|
@ -1,5 +1,16 @@
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
|
void ft_delrbt(t_node *node, void (*f)(void *data)) {
|
||||||
|
if (!(node)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ft_delrbt(node->left, f);
|
||||||
|
ft_delrbt(node->right, f);
|
||||||
|
f((void *)node);
|
||||||
|
free(node->data);
|
||||||
|
free(node);
|
||||||
|
}
|
||||||
|
|
||||||
void ft_putrbt(t_node *node, void (*f)(void *data)) {
|
void ft_putrbt(t_node *node, void (*f)(void *data)) {
|
||||||
if (!(node)) {
|
if (!(node)) {
|
||||||
return;
|
return;
|
||||||
|
|
3
libft.h
3
libft.h
|
@ -6,7 +6,7 @@
|
||||||
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2015/11/24 12:52:28 by gbrochar #+# #+# */
|
/* Created: 2015/11/24 12:52:28 by gbrochar #+# #+# */
|
||||||
/* Updated: 2024/10/20 18:36:39 by gbrochar ### ########.fr */
|
/* Updated: 2024/10/25 13:56:13 by gbrochar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ typedef t_node t_leaf;
|
||||||
void ft_rbt_insert(t_root **root, t_node *z, int (*f)(void *a, void *b));
|
void ft_rbt_insert(t_root **root, t_node *z, int (*f)(void *a, void *b));
|
||||||
t_node *ft_rbt_new(void *data, size_t size);
|
t_node *ft_rbt_new(void *data, size_t size);
|
||||||
void ft_putrbt(t_node *node, void (*f)(void *data));
|
void ft_putrbt(t_node *node, void (*f)(void *data));
|
||||||
|
void ft_delrbt(t_node *node, void (*f)(void *data));
|
||||||
void ft_lstadd(t_list **alst, t_list *new);
|
void ft_lstadd(t_list **alst, t_list *new);
|
||||||
void ft_lstadd_back(t_list **alst, t_list *new);
|
void ft_lstadd_back(t_list **alst, t_list *new);
|
||||||
void ft_lstinsert(t_list **lst, t_list *new, int (*f)(t_list *a, t_list *b));
|
void ft_lstinsert(t_list **lst, t_list *new, int (*f)(t_list *a, t_list *b));
|
||||||
|
|
Loading…
Reference in New Issue