-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops_rotate_bonus.c
49 lines (43 loc) · 1.35 KB
/
ops_rotate_bonus.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
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ops_rotate_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mehkekli <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 15:13:18 by mehkekli #+# #+# */
/* Updated: 2024/01/04 15:13:20 by mehkekli ### ########.fr */
/* */
/* ************************************************************************** */
#include "lib/libft/libft.h"
static void ft_rotate(t_list **stack)
{
t_list *tmp;
t_list *last;
if (!stack || !*stack || !(*stack)->next)
return ;
tmp = *stack;
*stack = (*stack)->next;
last = *stack;
while (last->next)
last = last->next;
last->next = tmp;
tmp->next = NULL;
}
void ft_ra(t_list **a)
{
if (*a)
ft_rotate(a);
}
void ft_rb(t_list **b)
{
if (*b)
ft_rotate(b);
}
void ft_rr(t_list **a, t_list **b)
{
if (*a)
ft_rotate(a);
if (*b)
ft_rotate(b);
}