-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevrot.c
48 lines (43 loc) · 1.55 KB
/
revrot.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* revrot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgerda <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/23 20:48:32 by bgerda #+# #+# */
/* Updated: 2020/02/23 20:50:08 by bgerda ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void revrotb(t_stack *stack_a, t_stack *stack_b)
{
t_node *tmp;
int tailmidpoint;
int headmidpoint;
int part;
tmp = stack_b->tail;
part = tmp->range;
tailmidpoint = tmp->range;
headmidpoint = stack_b->head->range;
while (tmp && part == tmp->range && tailmidpoint >= headmidpoint)
{
rr_ab(stack_b, tmp->range);
tmp = stack_b->head;
if (tmp->data >= tailmidpoint)
p_ab(stack_b, stack_a, tailmidpoint);
tmp = stack_b->tail;
}
}
void revrota(t_stack *stack)
{
t_properties *counters;
t_node *tmp;
tmp = stack->tail;
counters = stack->prop;
while (counters->stop && counters->count_rot)
{
rr_ab(stack, tmp->range);
tmp = stack->tail;
}
}