norm for lst functions done
This commit is contained in:
parent
e4a7afd78b
commit
0ea04b92f9
6 changed files with 62 additions and 67 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:11:54 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/04 11:47:22 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:09:15 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:12:28 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/04 12:00:41 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,35 +14,23 @@
|
|||
|
||||
void ft_lst_delsub(
|
||||
t_list **alst,
|
||||
t_list *sub, int (*cmp)(),
|
||||
t_list *sub,
|
||||
int (*cmp)(),
|
||||
void (*del)(void *, size_t))
|
||||
{
|
||||
t_list *last;
|
||||
t_list *current;
|
||||
t_list *tmp;
|
||||
t_list **indirect;
|
||||
|
||||
last = NULL;
|
||||
current = *alst;
|
||||
tmp = NULL;
|
||||
while (current && sub)
|
||||
indirect = alst;
|
||||
while (*indirect)
|
||||
{
|
||||
if ((*cmp)(current->content, sub->content) == 0)
|
||||
if ((*cmp)((*indirect)->content, sub->content) == 0)
|
||||
{
|
||||
if (current == *alst)
|
||||
*alst = current->next;
|
||||
else
|
||||
last->next = current->next;
|
||||
tmp = current;
|
||||
current = current->next;
|
||||
sub = sub->next;
|
||||
tmp = *indirect;
|
||||
(*indirect) = (*indirect)->next;
|
||||
ft_lstdelone(&tmp, del);
|
||||
sub = sub->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
last = current;
|
||||
current = current->next;
|
||||
}
|
||||
if (!current && sub)
|
||||
current = *alst;
|
||||
indirect = &(*indirect)->next;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,43 +6,36 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:09:25 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:09:26 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/04 12:01:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void ft_lst_delsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t))
|
||||
void ft_lst_order_delsub(
|
||||
t_list **alst,
|
||||
t_list *sub,
|
||||
int (*cmp)(),
|
||||
void (*del)(void *, size_t))
|
||||
{
|
||||
t_list *last;
|
||||
t_list *current;
|
||||
t_list *tmp;
|
||||
t_list **indirect;
|
||||
|
||||
last = NULL;
|
||||
current = *alst;
|
||||
tmp = NULL;
|
||||
while (current && sub)
|
||||
indirect = alst;
|
||||
while (*indirect)
|
||||
{
|
||||
if ((*cmp)(current->content, sub->content) > 0)
|
||||
if ((*cmp)((*indirect)->content, sub->content) > 0)
|
||||
{
|
||||
sub = sub->next;
|
||||
continue ;
|
||||
}
|
||||
if ((*cmp)(current->content, sub->content) == 0)
|
||||
if ((*cmp)((*indirect)->content, sub->content) == 0)
|
||||
{
|
||||
if (current == *alst)
|
||||
*alst = current->next;
|
||||
else
|
||||
last->next = current->next;
|
||||
tmp = current;
|
||||
current = current->next;
|
||||
sub = sub->next;
|
||||
tmp = *indirect;
|
||||
(*indirect) = (*indirect)->next;
|
||||
ft_lstdelone(&tmp, del);
|
||||
sub = sub->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
last = current;
|
||||
current = current->next;
|
||||
}
|
||||
indirect = &(*indirect)->next;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:09:31 by jhalford ### ########.fr */
|
||||
/* Updated: 2016/11/04 11:59:13 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,31 +14,21 @@
|
|||
|
||||
t_list *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)())
|
||||
{
|
||||
t_list *last;
|
||||
t_list *current;
|
||||
t_list *tmp;
|
||||
t_list **indirect;
|
||||
|
||||
last = NULL;
|
||||
tmp = NULL;
|
||||
current = *alst;
|
||||
indirect = alst;
|
||||
while (current)
|
||||
{
|
||||
if ((*cmp)(current->content, data_ref) == 0)
|
||||
if ((*cmp)((*indirect)->content, data_ref) == 0)
|
||||
{
|
||||
if (current == *alst)
|
||||
*alst = current->next;
|
||||
else
|
||||
last->next = current->next;
|
||||
tmp = current;
|
||||
current = current->next;
|
||||
tmp = (*indirect);
|
||||
tmp->next = NULL;
|
||||
(*indirect) = (*indirect)->next;
|
||||
return (tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
last = current;
|
||||
current = current->next;
|
||||
}
|
||||
indirect = &(*indirect)->next;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_debug.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:45:16 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:45:51 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -6,6 +18,6 @@ void ft_debug(void)
|
|||
static int n = 0;
|
||||
|
||||
n++;
|
||||
printf("----------\n check %02i\n----------\n", n);
|
||||
ft_printf("----------\n check %02i\n----------\n", n);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_path_notdir.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/04 11:45:07 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/04 11:45:08 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_path_notdir(char *path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue