-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_swap.h
More file actions
91 lines (73 loc) · 2.69 KB
/
Copy pathpush_swap.h
File metadata and controls
91 lines (73 loc) · 2.69 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kenakamu <kenakamu@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/14 11:47:53 by kenakamu #+# #+# */
/* Updated: 2025/09/12 13:53:08 by kenakamu ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUSH_SWAP_H
# define PUSH_SWAP_H
# include <unistd.h>
# include <stdlib.h>
# include <stdbool.h>
# include "libft/libft.h"
# define SUCCESS 0
# define FAILURE 1
typedef struct t_node
{
long long number;
long long rank;
struct t_node *next;
struct t_node *prev;
} t_node;
typedef struct t_stack
{
t_node *head;
t_node *tail;
} t_stack;
typedef struct t_pushswap
{
t_stack stack_a;
t_stack stack_b;
} t_pushswap;
long long add_to_tail(t_stack *stack, int num);
int stack_head_to_head(t_stack *dst, t_stack *src);//push
int move_tail_to_head(t_stack *Stack);//reverse_rotate
int move_head_to_tail(t_stack *Stack);//rotate
int swap(t_stack *stack);
void sa(t_pushswap *ps);
void sb(t_pushswap *ps);
void ss(t_pushswap *ps);
void pa(t_pushswap *ps);
void pb(t_pushswap *ps);
void ra(t_pushswap *ps);
void rb(t_pushswap *ps);
void rr(t_pushswap *ps);
void rra(t_pushswap *ps);
void rrb(t_pushswap *ps);
void rrr(t_pushswap *ps);
long long add_to_tail(t_stack *stack, int num);
int stack_head_to_head(t_stack *dst, t_stack *src);
int move_head_to_tail(t_stack *stack);
int move_tail_to_head(t_stack *stack);
int swap(t_stack *stack);
long long count_elements(t_pushswap *ps);
bool is_already_sorted(t_pushswap *ps);
bool is_value_duplicated(t_pushswap *ps, long long num);
bool is_integer(const char *nptr);
long long ft_atoll(const char *nptr);
void radix_lsd(t_pushswap *ps);
long long *bubble(long long *rank, int elements);
int ranking_nodes(t_pushswap *ps);
void elements_are_two(t_pushswap *ps);
void elements_are_three(t_pushswap *ps);
void elements_are_four(t_pushswap *ps);
void elements_are_five(t_pushswap *ps);
void free_stack(t_stack *stack);
int pushswap(char **ptrr, int elements);
void end_program(int exit_status, t_pushswap *ps);
#endif