-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_swap.h
93 lines (71 loc) · 2.85 KB
/
push_swap.h
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
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tpiras <tpiras@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/20 16:02:46 by ertiz #+# #+# */
/* Updated: 2023/05/23 15:42:08 by tpiras ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PUSH_SWAP_H
# define PUSH_SWAP_H
# include <limits.h>
# include <stdlib.h>
# include <stdio.h>
# include <stdbool.h>
# include <unistd.h>
# include "libft/libft.h"
typedef struct s_stack
{
int nbr;
int act_index;
int value;
bool ab_median;
bool cheapest;
struct s_stack *target_node;
struct s_stack *next;
struct s_stack *prev;
} t_stack;
//stack initialization functions (stack_init.c)
t_stack *find_last_node(t_stack *head);
void append_node(t_stack **stack, int nbr);
void stack_init(t_stack **a, char **av, int flag_ac2);
//push moves functions (push.c)
void pa(t_stack **a, t_stack **b, bool check);
void pb(t_stack **a, t_stack **b, bool check);
//swap moves functions (swap.c)
void sa(t_stack **a, bool check);
void sb(t_stack **b, bool check);
void ss(t_stack **a, t_stack **b, bool check);
//rotate moves functions (rotate.c)
void ra(t_stack **a, bool check);
void rb(t_stack **b, bool check);
void rr(t_stack **a, t_stack **b, bool check);
//reverse rotate moves functions (reverse_rotate.c)
void rra(t_stack **a, bool check);
void rrb(t_stack **b, bool check);
void rrr(t_stack **a, t_stack **b, bool check);
//initialization functions (init.c)
void set_current_position(t_stack *stack);
void init_nodes(t_stack *a, t_stack *b);
//sorting and cheacking functions (push_swap_utils.c & short_sort.c)
int stack_len(t_stack *stack);
void node_evaluation(t_stack *a, t_stack *b);
void sorty(t_stack **a);
void handle_five(t_stack **a, t_stack **b);
void set_cheapest(t_stack *b);
bool is_sorted(t_stack *stack);
t_stack *return_cheapest(t_stack *stack);
t_stack *is_smallest(t_stack *stack);
//push_swap algoritm (push_swap.c)
void finish_rotation(t_stack **stack, t_stack *top, char stack_name);
void push_swap(t_stack **a, t_stack **b);
//errors menagement (errors.c)
int error_repetation(t_stack *a, int nbr);
int error_syntax(char *str_nbr);
void error_free(t_stack **a, char **av, bool flag_ac2);
void free_stack(t_stack **stack);
void free_matrix(char **av);
#endif