-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_utils.c
More file actions
95 lines (84 loc) · 2.15 KB
/
list_utils.c
File metadata and controls
95 lines (84 loc) · 2.15 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
92
93
94
95
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbeaufre <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/16 10:23:00 by rbeaufre #+# #+# */
/* Updated: 2019/11/27 18:34:39 by rbeaufre ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
int ft_is_neighbor_with_name_hash(t_node *node, long hash)
{
t_node *node2;
t_list *tmp;
if (node == NULL)
return (0);
tmp = node->next;
while (tmp && tmp->next)
{
node2 = (t_node *)tmp->content;
if (node2->name_hash == hash)
return (1);
tmp = tmp->next;
}
return (0);
}
t_node *ft_find_t_node_with_id(t_list **list, int id)
{
t_node *node;
t_list *tmp;
tmp = *list;
while (tmp && tmp->next)
{
node = (t_node *)tmp->content;
if (node->id == id)
return (node);
tmp = tmp->next;
}
return (NULL);
}
t_node *ft_find_t_node_with_name_hash(t_list **list, long hash)
{
t_node *node;
t_list *tmp;
tmp = *list;
while (tmp && tmp->next)
{
node = (t_node *)tmp->content;
if (node->name_hash == hash)
return (node);
tmp = tmp->next;
}
return (NULL);
}
t_node *ft_find_t_node_with_start(t_list **list)
{
t_node *node;
t_list *tmp;
tmp = *list;
while (tmp && tmp->next)
{
node = (t_node *)tmp->content;
if (node->is_start == 1)
return (node);
tmp = tmp->next;
}
return (NULL);
}
t_node *ft_find_t_node_with_end(t_list **list)
{
t_node *node;
t_list *tmp;
tmp = *list;
while (tmp && tmp->next)
{
node = (t_node *)tmp->content;
if (node->is_end == 1)
return (node);
tmp = tmp->next;
}
return (NULL);
}