-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_rotate.c
45 lines (39 loc) · 1.29 KB
/
move_rotate.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* move_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: coskelet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/02 13:02:48 by coskelet #+# #+# */
/* Updated: 2022/03/04 14:48:11 by coskelet ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
static void rotate(t_list **lst)
{
t_list *tmp;
if (NULL == (*lst)->next)
return ;
tmp = *lst;
ft_lstlast(*lst)->next = *lst;
*lst = tmp->next;
tmp->next = NULL;
}
void rotate_a(t_stacks *st)
{
if (NULL == st->a)
return ;
rotate(&(st->a));
}
void rotate_b(t_stacks *st)
{
if (NULL == st->b)
return ;
rotate(&(st->b));
}
void rotate_both(t_stacks *st)
{
rotate_a(st);
rotate_b(st);
}