This commit is contained in:
kinou-p 2022-01-18 22:43:43 +01:00
parent 1f5c92e0b0
commit bf24b5da96
2 changed files with 0 additions and 115 deletions

View File

@ -1,37 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* indexing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/05 03:23:29 by apommier #+# #+# */
/* Updated: 2022/01/05 03:23:29 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void lst_indexing(t_list *list)
{
int index;
t_list *swap;
t_list *save;
swap = list;
save = list;
index = 0;
while (save)
{
index = 1;
while (swap)
{
if (*(int *)save->nbr > *(int *)swap->nbr)
index++;
swap = swap->next;
}
save->index = index;
swap = list;
save = save->next;
}
}

View File

@ -1,78 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/17 11:52:37 by apommier #+# #+# */
/* Updated: 2022/01/17 11:52:37 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ft_sa_sb(t_list **list, t_slist **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"));
}
}
void ft_ra_rb(t_list **list, t_slist **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, t_slist **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"));
return (*list_b);
}
void ft_pb(t_list **list_a, t_list **list_b, t_slist **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"));
}
void ft_rra_rrb(t_list **list, t_slist **process, char type)
{
t_list *swap;
swap = ft_lstlast(*list);
ft_lstbeforelast(*list)->next = 0;
ft_lstadd_front(list, swap);
if (type == 'a')
s_lstadd_back(process, new_slist("rra"));
else if (type == 'b')
s_lstadd_back(process, new_slist("rrb"));
}