-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_utils2.c
More file actions
63 lines (56 loc) · 1.51 KB
/
list_utils2.c
File metadata and controls
63 lines (56 loc) · 1.51 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yaqliu <yaqliu@student.42barcelona.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/07 14:09:03 by yaqliu #+# #+# */
/* Updated: 2026/02/12 01:07:41 by yaqliu ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
int stack_size(t_stack *stack)
{
int i;
i = 0;
if (stack)
{
i = 1;
while (stack->next)
{
stack = stack->next;
i++;
}
}
return (i);
}
int get_max_rank(t_stack *s)
{
int max;
t_stack *tmp;
max = -1;
tmp = s;
while (tmp)
{
if (tmp->r_pos > max)
max = tmp->r_pos;
tmp = tmp->next;
}
return (max);
}
int *ft_create_index(char **input, int size, int i)
{
int *index;
int ini;
ini = i;
index = (int *)malloc((size - ini) * sizeof(int));
i = 0;
while (i < size - ini)
{
index[i] = (int)ft_atol(input[ini + i]);
i++;
}
quick_sort_array(index, 0, (size - ini) - 1);
return (index);
}