-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap.h
42 lines (35 loc) · 1.46 KB
/
map.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/01 11:07:39 by mihykim #+# #+# */
/* Updated: 2020/06/01 13:26:14 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MAP_H
# define MAP_H
# define BASE 109
# define BIG_PRIME 1000003
# include <stdlib.h>
# include <string.h>
typedef struct s_node
{
const char *key;
void *value;
struct s_node *next;
} t_node;
typedef struct s_hash_map
{
unsigned int size;
t_node **map;
} t_hash_map;
t_hash_map *map_init(void);
int map_insert(t_hash_map *map, const char *key, void *value);
unsigned int get_hash(const char *key);
void *map_get(t_hash_map *map, const char *key);
void *map_delete(t_hash_map *map, const char *key);
void free_map(t_hash_map *map, void (*free_data)(void *));
#endif