data_structures
src
data_structures
hashset
hashset_contains.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* hashset_contains.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2020/07/21 19:53:13 by unite #+# #+# */
10
/* Updated: 2020/09/03 22:50:14 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
hashset.h
"
15
#include "
hashset_utils.h
"
16
17
int
hashset_contains
(
const
t_hashset
*hs,
const
void
*val)
18
{
19
size_t
ind;
20
21
ind = hs->
type
->
hash
(val, hs->
capacity
);
22
while
(hs->
vals
[ind] != NULL)
23
{
24
if
(hs->
type
->
cmp
(hs->
vals
[ind], val) == 0)
25
return
(1);
26
ind = (ind + 1) % hs->
capacity
;
27
}
28
return
(0);
29
}
s_hashset::capacity
size_t capacity
The current capacity of the hashset.
Definition:
hashset.h:47
hashset_contains
int hashset_contains(const t_hashset *hs, const void *val)
Is the specified element contained in the set?
Definition:
hashset_contains.c:17
hashset_utils.h
s_type::cmp
int(* cmp)(const void *, const void *)
(optional) A function ponter used to compare members of this data type
Definition:
types.h:52
hashset.h
s_hashset::vals
void ** vals
The data.
Definition:
hashset.h:45
s_type::hash
size_t(* hash)(const void *, size_t)
(optional) A function pointer used to get a hash value of this data type
Definition:
types.h:53
s_hashset
A dynamically resizing linear-probing hashset.
Definition:
hashset.h:43
s_hashset::type
const t_type * type
The type of elements in the hashset.
Definition:
hashset.h:48
Generated by
1.8.16