-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_1.c
59 lines (53 loc) · 1.44 KB
/
utils_1.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <kotto555555@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/29 14:58:04 by kakiba #+# #+# */
/* Updated: 2023/01/15 21:15:33 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int issort(t_dlist *a)
{
while (a->next)
{
if (a ->content > a->next->content)
return (0);
a = a -> next;
}
return (1);
}
t_dlist *ft_dlstlast_nfinish(t_dlist *lst)
{
if (lst == NULL)
return (NULL);
while (lst -> next != NULL)
{
if (lst -> next -> i_done == 1)
break ;
lst = lst -> next;
}
return (lst);
}
size_t dlist_nset_size(t_dlist *lst)
{
size_t nset;
nset = 0;
while (lst)
{
if (lst -> i_done == 0)
++nset;
lst = lst -> next;
}
return (nset);
}
int abs(int x)
{
if (x < 0)
return (-x);
else
return (x);
}