asdflkaj
This commit is contained in:
26
stack/ft_stackadd_back.c
Normal file
26
stack/ft_stackadd_back.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stackadd_back.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/05 11:40:39 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/05 11:42:15 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
void ft_stackadd_back(t_stack **stack, t_stack *new)
|
||||
{
|
||||
if (!stack)
|
||||
return ;
|
||||
if (!*stack)
|
||||
{
|
||||
(*stack) = new;
|
||||
return ;
|
||||
}
|
||||
ft_stacklast(*stack)->next = new;
|
||||
}
|
||||
|
24
stack/ft_stackadd_front.c
Normal file
24
stack/ft_stackadd_front.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stackadd_front.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/04 18:52:38 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/05 11:38:54 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
void ft_stackadd_front(t_stack **stack, t_stack *new)
|
||||
{
|
||||
if (!stack)
|
||||
return ;
|
||||
if (!new)
|
||||
return ;
|
||||
new->next = *stack;
|
||||
*stack = new;
|
||||
}
|
||||
|
27
stack/ft_stackclear.c
Normal file
27
stack/ft_stackclear.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stackclear.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/04 18:54:56 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/05 11:39:22 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
void ft_stackclear(t_stack **stack)
|
||||
{
|
||||
t_stack *tmp;
|
||||
|
||||
tmp = NULL;
|
||||
while (stack && *stack)
|
||||
{
|
||||
tmp = (*stack)->next;
|
||||
ft_stackdelone(*stack);
|
||||
*stack = tmp;
|
||||
}
|
||||
}
|
||||
|
21
stack/ft_stackdelone.c
Normal file
21
stack/ft_stackdelone.c
Normal file
@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stackdelone.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/06 10:27:14 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/06 10:28:24 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
void ft_stackdelone(t_stack *stack)
|
||||
{
|
||||
if (stack == NULL)
|
||||
return ;
|
||||
free(stack);
|
||||
}
|
||||
|
27
stack/ft_stacklast.c
Normal file
27
stack/ft_stacklast.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stacklast.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/06 10:18:01 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/08 16:24:36 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
t_stack *ft_stacklast(t_stack *stack)
|
||||
{
|
||||
t_stack *tmp;
|
||||
|
||||
if (!stack)
|
||||
return (NULL);
|
||||
tmp = stack;
|
||||
while (tmp->next)
|
||||
tmp = tmp->next;
|
||||
return (tmp);
|
||||
|
||||
}
|
||||
|
26
stack/ft_stacknew.c
Normal file
26
stack/ft_stacknew.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stacknew.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/05 11:45:19 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/05 14:11:46 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
t_stack *ft_stacknew(int nb)
|
||||
{
|
||||
t_stack *stack;
|
||||
|
||||
stack = malloc(sizeof(t_stack));
|
||||
if (!stack)
|
||||
return (NULL);
|
||||
stack->nb = nb;
|
||||
stack->next = NULL;
|
||||
return (stack);
|
||||
}
|
||||
|
27
stack/ft_stacksize.c
Normal file
27
stack/ft_stacksize.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_stacksize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/05 11:42:40 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/05 11:44:21 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../push_swap.h"
|
||||
|
||||
size_t ft_stacksize(t_stack *stack)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (stack)
|
||||
{
|
||||
stack = stack->next;
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
Reference in New Issue
Block a user