72 lines
2.2 KiB
C
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"
|
|
|
|
void ft_sa_sb(t_list **list, t_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)
|
|
ft_lstadd_back(process, new_slist("sa"));
|
|
else
|
|
ft_lstadd_back(process, new_slist("sb"));
|
|
}
|
|
}
|
|
|
|
void ft_ra_rb(t_list **list, t_list **process, char type)
|
|
{
|
|
t_list *swap;
|
|
|
|
swap = *list;
|
|
(ft_lstlast(*list))->next = *list;
|
|
*list = (*list)->next;
|
|
swap->next = 0;
|
|
if (type)
|
|
ft_lstadd_back(process, new_slist("ra"));
|
|
else
|
|
ft_lstadd_back(process, new_slist("rb"));
|
|
}
|
|
|
|
void ft_pa(t_list **list_a, t_list **list_b, t_list **process)
|
|
{
|
|
t_list *swap;
|
|
|
|
swap = *list_b;
|
|
*list_b = (*list_b)->next;
|
|
ft_lstadd_front(list_a, swap);
|
|
ft_lstadd_back(process, new_slist("pa"));
|
|
}
|
|
|
|
void ft_pb(t_list **list_a, t_list **list_b, t_list **process)
|
|
{
|
|
t_list *swap;
|
|
|
|
swap = *list_a;
|
|
*list_a = (*list_a)->next;
|
|
ft_lstadd_front(list_b, swap);
|
|
ft_lstadd_back(process, new_slist("pb"));
|
|
}
|
|
|
|
void ft_rra_rrb(t_list **list, t_list **process, char type)
|
|
{
|
|
t_list *swap;
|
|
|
|
swap = *list;
|
|
}
|