-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
60 lines (51 loc) · 1.61 KB
/
ft_lstsize.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
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lgasc <lgasc@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:28:09 by lgasc #+# #+# */
/* Updated: 2024/02/27 21:29:19 by lgasc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
///Count the number of nodes in a list
///@param list The beginning of the list.
///@return The length of the list.
__attribute__ ((warn_unused_result))
size_t ft_lstsize(const t_list list)
{
t_node *node;
size_t size;
node = list;
size = 0;
while (node != NULL)
{
size++;
node = node->next;
}
return (size);
}
__attribute__ ((warn_unused_result))
size_t ft_ilstsize(const t_ilist list)
{
size_t size;
t_inode *node;
node = list;
size = 0;
while (node != NULL)
node = (++size, node->next);
return (size);
}
__attribute__ ((warn_unused_result))
size_t ft_zlstsize(const t_zlist list)
{
size_t size;
t_znode *node;
node = list;
size = 0;
while (node != NULL)
node = (++size, node->next);
return (size);
}