forked from remzi-arpacidusseau/ostep-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.h
40 lines (38 loc) · 1013 Bytes
/
hash.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
#ifndef HASH_H
#define HASH_H
#include <assert.h>
#define CAPACITY 200 // Size of the HashTable.
// Defines the HashTable item.
#define VALUE_SIZE 100
typedef struct Ht_item
{
char *key;
char **value;
int value_list_len;
int store_to_overflow_buckets;
int get_next_index;
} Ht_item;
// Defines the LinkedList.
typedef struct linkedList
{
Ht_item *item;
struct linkedList *next;
} LinkedList;
// Defines the HashTable.
typedef struct HashTable
{
// Contains an array of pointers to items.
Ht_item **items;
LinkedList **overflow_buckets;
int size;
int count;
} HashTable;
HashTable *create_table(int size);
void free_item(Ht_item *item);
void ht_insert(HashTable *table, char *key, char *value);
void free_table(HashTable *table);
void print_table(HashTable *table);
void append_item_value(char *value,Ht_item *item);
char *ht_search_with_get_next(HashTable *table, char *key);
char *ht_search_with_get_next_partition(HashTable *table, char *key, int index);
#endif