-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap.h
More file actions
31 lines (25 loc) · 697 Bytes
/
Copy pathhashmap.h
File metadata and controls
31 lines (25 loc) · 697 Bytes
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
#ifndef HASHMAP_H
#define HASHMAP_H
typedef enum DataType {
FREQ_TYPE,
STR_TYPE
} DataType;
typedef union BucketData {
char *string;
int freq;
} BucketData;
typedef struct BucketItem {
char *key;
BucketData *data;
} BucketItem;
typedef struct HashMap {
BucketItem **buckets;
DataType type; /* Type of data the hashmap stores, either integer or pointer to string */
int size;
int filled; /* How much of the buckets is filled */
} HashMap;
HashMap *initialize_hashmap(int size, DataType type);
int insert_hashmap(HashMap *map, char *key, BucketData *data);
BucketData *get_hashmap(HashMap *map, char *key);
int hash_code(HashMap *map, char *key);
#endif