-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_a.c
More file actions
63 lines (56 loc) · 1.62 KB
/
stack_a.c
File metadata and controls
63 lines (56 loc) · 1.62 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_a.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: algungor <algungor@student.42istanbul.com.t+#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/27 13:45:47 by algungor #+# #+# */
/* Updated: 2026/05/03 14:21:07 by algungor ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void m_sa(t_stack **a)
{
t_stack *one;
t_stack *two;
if (!a || !*a || !(*a)->next)
return ;
one = *a;
two = (*a)->next;
one->next = two->next;
if (two->next)
two->next->prev = one;
two->next = one;
two->prev = NULL;
one->prev = two;
*a = two;
}
void m_ra(t_stack **a)
{
t_stack *one;
t_stack *lst;
if (!a || !*a || !(*a)->next)
return ;
one = *a;
*a = (*a)->next;
(*a)->prev = NULL;
one->next = NULL;
lst = stack_last(*a);
lst->next = one;
one->prev = lst;
}
void m_rra(t_stack **a)
{
t_stack *last;
t_stack *new_last;
if (!a || !*a || !(*a)->next)
return ;
last = stack_last(*a);
new_last = last->prev;
new_last->next = NULL;
last->next = *a;
(*a)->prev = last;
last->prev = NULL;
*a = last;
}