-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset_exists.c
34 lines (30 loc) · 1.29 KB
/
set_exists.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set_exists.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/31 21:08:32 by mihykim #+# #+# */
/* Updated: 2020/05/31 23:19:45 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "set.h"
# define EXISTENT 1
# define NON_EXISTENT 0
int set_exists(t_hash_set *set, void *data, unsigned int data_size)
{
t_node *curr;
unsigned int i;
if (set == NULL || data == NULL || data_size == 0)
return (NON_EXISTENT);
i = get_hash(data, data_size);
curr = set->set[i];
while (curr)
{
if (set->cmp(curr->data, data) == 0)
return (EXISTENT);
curr = curr->next;
}
return (NON_EXISTENT);
}