-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashset.h
69 lines (57 loc) · 1.39 KB
/
hashset.h
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
//
// Created by Emanuel on 03.09.2024.
//
#ifndef HASHSET_H
#define HASHSET_H
#include <stddef.h>
#include <stdbool.h>
typedef struct HashSet *HashSet;
typedef size_t (*hash)(const void *key, size_t key_size);
/**
* @brief Creates a new HashSet with a hash function.
*
* @param hs_capacity The initial capacity of the HashSet
* @param key_size The sizeof value of the key
* @param hash_func a custom hash function. Pass NULL for generic hashing.
* @return HashSet
*/
HashSet hs_create(size_t hs_capacity, size_t key_size, hash hash_func);
/**
* @brief Destroys the HashSet.
*
* @param hs The HashSet
* @return Success code
*/
int hs_destroy(HashSet hs);
/**
* @brief Tests if the HashSet contains the specified key.
*
* @param hs The HashSet
* @param key The key
* @return True or Falsehood
*/
bool hs_contains(HashSet hs, const void *key);
/**
* @brief Adds a new key to the HashSet.
*
* @param hs The HashSet
* @param key The key
* @return Success code
*/
int hs_add(HashSet hs, const void *key);
/**
* @brief Returns the size of the HashSet.
*
* @param hs The HashSet
* @return The size
*/
size_t hs_size(HashSet hs);
/**
* @brief Removes the key from the HashSet.
*
* @param hs The HashSet
* @param key The key
* @return Success code
*/
int hs_remove(HashSet hs, const void *key);
#endif //HASHSET_H