Push_swap/process.c
2022-01-10 21:34:59 +01:00

72 lines
2.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/25 23:15:09 by apommier #+# #+# */
/* Updated: 2021/11/25 23:15:09 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
t_list *ft_sa_sb(t_list **list, s_list **process, char type, int set)
{
t_list *swap;
swap = (*list)->next->next;
(*list)->next->next = *list;
*list = (*list)->next;
(*list)->next->next = swap;
if (set)
{
if (type = 'a')
s_lstadd_back(process, new_slist("sa"));
else if (type = 'b')
s_lstadd_back(process, new_slist("sb"));
}
}
t_list *ft_ra_rb(t_list **list, s_list **process, char type)
{
t_list *swap;
swap = *list;
(ft_lstlast(*list))->next = *list;
*list = (*list)->next;
swap->next = 0;
if (type = 'a')
s_lstadd_back(process, new_slist("ra"));
else if (type = 'b')
s_lstadd_back(process, new_slist("rb"));
}
t_list *ft_pa(t_list **list_a, t_list **list_b, s_list **process)
{
t_list *swap;
swap = *list_b;
*list_b = (*list_b)->next;
ft_lstadd_front(list_a, swap);
s_lstadd_back(process, new_slist("pa"));
}
t_list *ft_pb(t_list **list_a, t_list **list_b, s_list **process)
{
t_list *swap;
swap = *list_a;
*list_a = (*list_a)->next;
ft_lstadd_front(list_b, swap);
s_lstadd_back(process, new_slist("pb"));
}
t_list * ft_rra_rrb(t_list **list, s_list **process, char type)
{
t_list *swap;
swap = *list;
}