win
This commit is contained in:
parent
e5371d0197
commit
e438fea669
434 changed files with 41314 additions and 14135 deletions
26
mlx/srcs/linked_lists/ft_lstadd_back.c
Normal file
26
mlx/srcs/linked_lists/ft_lstadd_back.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstadd_back.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <smaccary@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 16:50:17 by smaccary #+# #+# */
|
||||
/* Updated: 2020/06/13 15:21:25 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
void ft_lstadd_back(t_list **alst, t_list *new)
|
||||
{
|
||||
t_list *last;
|
||||
|
||||
if (!*alst)
|
||||
{
|
||||
*alst = new;
|
||||
return ;
|
||||
}
|
||||
last = ft_lstlast(*alst);
|
||||
last->next = new;
|
||||
}
|
||||
21
mlx/srcs/linked_lists/ft_lstadd_front.c
Normal file
21
mlx/srcs/linked_lists/ft_lstadd_front.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstadd_front.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 16:32:36 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/17 16:56:05 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
void ft_lstadd_front(t_list **alst, t_list *new)
|
||||
{
|
||||
if (!alst || !new)
|
||||
return ;
|
||||
new->next = *alst;
|
||||
*alst = new;
|
||||
}
|
||||
24
mlx/srcs/linked_lists/ft_lstchr.c
Normal file
24
mlx/srcs/linked_lists/ft_lstchr.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <smaccary@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 16:39:19 by smaccary #+# #+# */
|
||||
/* Updated: 2020/07/31 21:44:24 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
t_list *ft_lstchr(t_list *lst, void *find)
|
||||
{
|
||||
while (lst)
|
||||
{
|
||||
if (find == lst->content)
|
||||
return (lst);
|
||||
lst = lst->next;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
30
mlx/srcs/linked_lists/ft_lstclear.c
Normal file
30
mlx/srcs/linked_lists/ft_lstclear.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstclear.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: user42 <user42@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/12 15:51:15 by smaccary #+# #+# */
|
||||
/* Updated: 2020/07/10 23:06:47 by user42 ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *))
|
||||
{
|
||||
t_list *next;
|
||||
|
||||
if (!lst || !*lst)
|
||||
return ;
|
||||
next = (*lst)->next;
|
||||
while (next)
|
||||
{
|
||||
next = (*lst)->next;
|
||||
ft_lstdelone(*lst, del);
|
||||
*lst = next;
|
||||
}
|
||||
*lst = NULL;
|
||||
}
|
||||
35
mlx/srcs/linked_lists/ft_lstcpy.c
Normal file
35
mlx/srcs/linked_lists/ft_lstcpy.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/12 17:14:00 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/14 15:48:47 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
t_list *ft_lstcpy(t_list *lst, void (*del)(void *))
|
||||
{
|
||||
t_list *dst;
|
||||
t_list *dst_next;
|
||||
|
||||
if (!(dst = ft_lstnew(lst->content)))
|
||||
return (NULL);
|
||||
dst_next = dst;
|
||||
while (lst->next)
|
||||
{
|
||||
if (!(dst_next->next = ft_lstnew(lst->next->content)))
|
||||
{
|
||||
ft_lstclear(&dst, del);
|
||||
return (NULL);
|
||||
}
|
||||
lst = lst->next;
|
||||
dst_next = dst_next->next;
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
22
mlx/srcs/linked_lists/ft_lstdelone.c
Normal file
22
mlx/srcs/linked_lists/ft_lstdelone.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstdelone.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/12 14:08:06 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/17 16:50:42 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *))
|
||||
{
|
||||
if (!del || !lst || !(lst->content))
|
||||
return ;
|
||||
(*del)(lst->content);
|
||||
free(lst);
|
||||
}
|
||||
23
mlx/srcs/linked_lists/ft_lstiter.c
Normal file
23
mlx/srcs/linked_lists/ft_lstiter.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstiter.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/12 17:01:45 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/17 16:56:37 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
||||
{
|
||||
while (lst && f)
|
||||
{
|
||||
(*f)(lst->content);
|
||||
lst = lst->next;
|
||||
}
|
||||
}
|
||||
22
mlx/srcs/linked_lists/ft_lstlast.c
Normal file
22
mlx/srcs/linked_lists/ft_lstlast.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstlast.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 16:47:04 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/11 16:50:06 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
t_list *ft_lstlast(t_list *lst)
|
||||
{
|
||||
if (lst == NULL)
|
||||
return (NULL);
|
||||
while (lst->next)
|
||||
lst = lst->next;
|
||||
return (lst);
|
||||
}
|
||||
39
mlx/srcs/linked_lists/ft_lstmap.c
Normal file
39
mlx/srcs/linked_lists/ft_lstmap.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstmap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <smaccary@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/12 17:09:26 by smaccary #+# #+# */
|
||||
/* Updated: 2020/07/31 17:53:56 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
||||
{
|
||||
t_list *dst;
|
||||
t_list *dst_next;
|
||||
|
||||
if (!*f || !lst || !(dst = ft_lstnew((*f)(lst->content))))
|
||||
return (NULL);
|
||||
dst_next = dst;
|
||||
while (lst->next)
|
||||
{
|
||||
if (!(dst_next->next = ft_lstnew((*f)(lst->next->content))))
|
||||
{
|
||||
ft_lstclear(&dst, del);
|
||||
return (NULL);
|
||||
}
|
||||
if (dst_next->next->content == NULL)
|
||||
{
|
||||
ft_lstclear(&dst, del);
|
||||
return (NULL);
|
||||
}
|
||||
lst = lst->next;
|
||||
dst_next = dst_next->next;
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
25
mlx/srcs/linked_lists/ft_lstnew.c
Normal file
25
mlx/srcs/linked_lists/ft_lstnew.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstnew.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 15:40:57 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/16 18:53:06 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
t_list *ft_lstnew(void *content)
|
||||
{
|
||||
t_list *dst;
|
||||
|
||||
dst = malloc(sizeof(t_list));
|
||||
if (!dst)
|
||||
return (NULL);
|
||||
dst->content = content;
|
||||
dst->next = NULL;
|
||||
return (dst);
|
||||
}
|
||||
26
mlx/srcs/linked_lists/ft_lstsize.c
Normal file
26
mlx/srcs/linked_lists/ft_lstsize.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lstsize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/11 16:39:19 by smaccary #+# #+# */
|
||||
/* Updated: 2019/11/12 17:06:47 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "linked_lists.h"
|
||||
|
||||
int ft_lstsize(t_list *lst)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
while (lst)
|
||||
{
|
||||
lst = lst->next;
|
||||
len++;
|
||||
}
|
||||
return (len);
|
||||
}
|
||||
36
mlx/srcs/linked_lists/linked_lists.h
Normal file
36
mlx/srcs/linked_lists/linked_lists.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* linked_lists.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: smaccary <smaccary@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/07/31 17:51:32 by smaccary #+# #+# */
|
||||
/* Updated: 2020/07/31 17:51:32 by smaccary ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LINKED_LISTS_H
|
||||
# define LINKED_LISTS_H
|
||||
|
||||
# include <stdlib.h>
|
||||
|
||||
typedef struct s_list
|
||||
{
|
||||
void *content;
|
||||
struct s_list *next;
|
||||
} t_list;
|
||||
|
||||
void ft_lstadd_back(t_list **alst, t_list *new);
|
||||
void ft_lstadd_front(t_list **alst, t_list *new);
|
||||
t_list *ft_lstchr(t_list *lst, void *find);
|
||||
void ft_lstclear(t_list **lst, void (*del)(void *));
|
||||
t_list *ft_lstcpy(t_list *lst, void (*del)(void *));
|
||||
void ft_lstdelone(t_list *lst, void (*del)(void *));
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *));
|
||||
t_list *ft_lstlast(t_list *lst);
|
||||
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
|
||||
t_list *ft_lstnew(void *content);
|
||||
int ft_lstsize(t_list *lst);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue