norm for lst functions done
This commit is contained in:
parent
e4a7afd78b
commit
0ea04b92f9
6 changed files with 62 additions and 67 deletions
|
|
@ -6,15 +6,15 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
|
/* 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
void ft_lst_delif(
|
void ft_lst_delif(
|
||||||
t_list **alst,
|
t_list **alst,
|
||||||
void *data_ref, int (*cmp)(),
|
void *data_ref, int (*cmp)(),
|
||||||
void (*del)(void *, size_t))
|
void (*del)(void *, size_t))
|
||||||
{
|
{
|
||||||
t_list *last;
|
t_list *last;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:15 by jhalford #+# #+# */
|
/* 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(
|
void ft_lst_delsub(
|
||||||
t_list **alst,
|
t_list **alst,
|
||||||
t_list *sub, int (*cmp)(),
|
t_list *sub,
|
||||||
|
int (*cmp)(),
|
||||||
void (*del)(void *, size_t))
|
void (*del)(void *, size_t))
|
||||||
{
|
{
|
||||||
t_list *last;
|
|
||||||
t_list *current;
|
|
||||||
t_list *tmp;
|
t_list *tmp;
|
||||||
|
t_list **indirect;
|
||||||
|
|
||||||
last = NULL;
|
indirect = alst;
|
||||||
current = *alst;
|
while (*indirect)
|
||||||
tmp = NULL;
|
|
||||||
while (current && sub)
|
|
||||||
{
|
{
|
||||||
if ((*cmp)(current->content, sub->content) == 0)
|
if ((*cmp)((*indirect)->content, sub->content) == 0)
|
||||||
{
|
{
|
||||||
if (current == *alst)
|
tmp = *indirect;
|
||||||
*alst = current->next;
|
(*indirect) = (*indirect)->next;
|
||||||
else
|
|
||||||
last->next = current->next;
|
|
||||||
tmp = current;
|
|
||||||
current = current->next;
|
|
||||||
sub = sub->next;
|
|
||||||
ft_lstdelone(&tmp, del);
|
ft_lstdelone(&tmp, del);
|
||||||
|
sub = sub->next;
|
||||||
}
|
}
|
||||||
else
|
indirect = &(*indirect)->next;
|
||||||
{
|
|
||||||
last = current;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
if (!current && sub)
|
|
||||||
current = *alst;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,43 +6,36 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:25 by jhalford #+# #+# */
|
/* 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"
|
#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 *tmp;
|
||||||
|
t_list **indirect;
|
||||||
|
|
||||||
last = NULL;
|
indirect = alst;
|
||||||
current = *alst;
|
while (*indirect)
|
||||||
tmp = NULL;
|
|
||||||
while (current && sub)
|
|
||||||
{
|
{
|
||||||
if ((*cmp)(current->content, sub->content) > 0)
|
if ((*cmp)((*indirect)->content, sub->content) > 0)
|
||||||
{
|
{
|
||||||
sub = sub->next;
|
sub = sub->next;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
if ((*cmp)(current->content, sub->content) == 0)
|
if ((*cmp)((*indirect)->content, sub->content) == 0)
|
||||||
{
|
{
|
||||||
if (current == *alst)
|
tmp = *indirect;
|
||||||
*alst = current->next;
|
(*indirect) = (*indirect)->next;
|
||||||
else
|
|
||||||
last->next = current->next;
|
|
||||||
tmp = current;
|
|
||||||
current = current->next;
|
|
||||||
sub = sub->next;
|
|
||||||
ft_lstdelone(&tmp, del);
|
ft_lstdelone(&tmp, del);
|
||||||
|
sub = sub->next;
|
||||||
}
|
}
|
||||||
else
|
indirect = &(*indirect)->next;
|
||||||
{
|
|
||||||
last = current;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */
|
/* 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 *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)())
|
||||||
{
|
{
|
||||||
t_list *last;
|
|
||||||
t_list *current;
|
|
||||||
t_list *tmp;
|
t_list *tmp;
|
||||||
|
t_list **indirect;
|
||||||
|
|
||||||
last = NULL;
|
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
current = *alst;
|
indirect = alst;
|
||||||
while (current)
|
while (current)
|
||||||
{
|
{
|
||||||
if ((*cmp)(current->content, data_ref) == 0)
|
if ((*cmp)((*indirect)->content, data_ref) == 0)
|
||||||
{
|
{
|
||||||
if (current == *alst)
|
tmp = (*indirect);
|
||||||
*alst = current->next;
|
tmp->next = NULL;
|
||||||
else
|
(*indirect) = (*indirect)->next;
|
||||||
last->next = current->next;
|
|
||||||
tmp = current;
|
|
||||||
current = current->next;
|
|
||||||
return (tmp);
|
return (tmp);
|
||||||
}
|
}
|
||||||
else
|
indirect = &(*indirect)->next;
|
||||||
{
|
|
||||||
last = current;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (NULL);
|
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 "libft.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
@ -6,6 +18,6 @@ void ft_debug(void)
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
printf("----------\n check %02i\n----------\n", n);
|
ft_printf("----------\n check %02i\n----------\n", n);
|
||||||
fflush(stdout);
|
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"
|
#include "libft.h"
|
||||||
|
|
||||||
char *ft_path_notdir(char *path)
|
char *ft_path_notdir(char *path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue