-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_b.c
More file actions
63 lines (56 loc) · 1.61 KB
/
stack_b.c
File metadata and controls
63 lines (56 loc) · 1.61 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_b.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: algungor <algungor@student.42istanbul.com.t+#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/27 13:46:04 by algungor #+# #+# */
/* Updated: 2026/05/03 14:21:11 by algungor ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void m_sb(t_stack **b)
{
t_stack *one;
t_stack *two;
if (!b || !*b || !(*b)->next)
return ;
one = *b;
two = one->next;
one->next = two->next;
if (two->next)
two->next->prev = one;
two->next = one;
two->prev = NULL;
one->prev = two;
*b = two;
}
void m_rb(t_stack **b)
{
t_stack *one;
t_stack *lst;
if (!b || !*b || !(*b)->next)
return ;
one = *b;
*b = one->next;
(*b)->prev = NULL;
one->next = NULL;
lst = stack_last(*b);
lst->next = one;
one->prev = lst;
}
void m_rrb(t_stack **b)
{
t_stack *last;
t_stack *new_last;
if (!b || !*b || !(*b)->next)
return ;
last = stack_last(*b);
new_last = last->prev;
new_last->next = NULL;
last->next = *b;
(*b)->prev = last;
last->prev = NULL;
*b = last;
}