-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_rrotate.c
47 lines (41 loc) · 1.35 KB
/
move_rrotate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* move_rrotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: coskelet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/02 14:08:47 by coskelet #+# #+# */
/* Updated: 2022/03/02 14:35:00 by coskelet ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void rrotate(t_list **lst)
{
t_list *tmp_l;
t_list *tmp_sl;
if (NULL == (*lst)->next)
return ;
tmp_sl = ft_lstsublast(*lst);
tmp_l = ft_lstlast(*lst);
tmp_l->next = *lst;
*lst = tmp_l;
tmp_sl->next = NULL;
}
void rrotate_a(t_stacks *st)
{
if (NULL == st->a)
return ;
rrotate(&(st->a));
}
void rrotate_b(t_stacks *st)
{
if (NULL == st->b)
return ;
rrotate(&(st->b));
}
void rrotate_both(t_stacks *st)
{
rrotate_a(st);
rrotate_b(st);
}