-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashtable.h
More file actions
56 lines (42 loc) · 1.22 KB
/
Hashtable.h
File metadata and controls
56 lines (42 loc) · 1.22 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
/* Copyright 2021 <Tulpan Andrei> */
#ifndef HASHTABLE_H_
#define HASHTABLE_H_
#include "/home/student/LinkedList.h"
struct info {
void *key;
void *value;
};
typedef struct hashtable_t hashtable_t;
struct hashtable_t {
linked_list_t **buckets; /* Array de liste simplu-inlantuite. */
/* Nr. total de noduri existente curent in toate bucket-urile. */
unsigned int size;
unsigned int hmax; /* Nr. de bucket-uri. */
/* (Pointer la) Functie pentru a calcula valoarea hash asociata cheilor. */
unsigned int (*hash_function)(void*);
/* (Pointer la) Functie pentru a compara doua chei. */
int (*compare_function)(void*, void*);
};
hashtable_t *
ht_create(unsigned int hmax, unsigned int (*hash_function)(void*),
int (*compare_function)(void*, void*));
void
ht_put(hashtable_t *ht, void *key, unsigned int key_size,
void *value, unsigned int value_size);
void *
ht_get(hashtable_t *ht, void *key);
int
ht_has_key(hashtable_t *ht, void *key);
void
ht_remove_entry(hashtable_t *ht, void *key);
unsigned int
ht_get_size(hashtable_t *ht);
unsigned int
ht_get_hmax(hashtable_t *ht);
void
ht_free(hashtable_t *ht);
int
compare_function_ints(void *a, void *b);
int
compare_function_strings(void *a, void *b);
#endif /* HASHTABLE_H_ */