-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple_rotate.c
45 lines (42 loc) · 1.4 KB
/
multiple_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* multiple_rotate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nkawaguc <nkawaguc@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/19 23:07:37 by nkawaguc #+# #+# */
/* Updated: 2024/10/19 23:07:38 by nkawaguc ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void multiple_rotate_a(t_deque *stack_a, int rotate_a, t_optimizer *opt)
{
if (rotate_a == 0)
return ;
if (rotate_a > 0)
{
while (rotate_a--)
rotate_up(stack_a, OP_RA, opt);
}
else
{
while (rotate_a++)
rotate_down(stack_a, OP_RRA, opt);
}
}
void multiple_rotate_b(t_deque *stack_b, int rotate_b, t_optimizer *opt)
{
if (rotate_b == 0)
return ;
if (rotate_b > 0)
{
while (rotate_b--)
rotate_up(stack_b, OP_RB, opt);
}
else
{
while (rotate_b++)
rotate_down(stack_b, OP_RRB, opt);
}
}