-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashtable.h
More file actions
49 lines (43 loc) · 1.52 KB
/
hashtable.h
File metadata and controls
49 lines (43 loc) · 1.52 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
#pragma once
typedef struct hashtable {
int elementStride;
int elementLength;
char isPointerData;
void* memory;
} hashtable;
/**
* @brief Creates a hashtable and mallocs the needed memory
* @param elementStride the stride of the data stored
* @param elementLength the total length of the hashtable. (Maximum amount of
* elements). CANNOT be resized
* @param isPointerData will this hashtable be filled with pointers
* @param outHashtable the hashtable that is given to you. Which you can use in
* the other functions
*/
hashtable* hashtableCreate(int elementStride, int elementCnt,
char isPointerData);
/**
* @brief Fills the entire hashtable with param value. Will overwrite.
* @param *ht pointer to the hashtable
* @param *value the value you want the hashtable to be filled with
*/
void hashtableFill(hashtable* ht, void* value);
/**
* @brief Gets the value of key from the hashtable
* @param *ht pointer to the hashtable
* @param *key key string to the value
* @param *outValue the pointer to the value
*/
void hashtableGet(hashtable* ht, const char* key, void* outValue);
/**
* @brief Sets the value of key in the given hashtable
* @param *ht pointer to the hashtable
* @param *key key string to the value you want to Sets
* @param *value value you want to set key to
*/
char hashtableSet(hashtable* ht, const char* key, void* value);
/**
* @brief Destroy the given hashtable. Frees all memory
* @param *ht pointer to the hashtable
*/
void hashtableDestroy(hashtable* ht);