-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHash.h
48 lines (32 loc) · 1.33 KB
/
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
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>
// Header file containing functions needed for hash table
// define data struct
// position is the current string/move the program is analyzing
// from is the move that came before the position string
// steps is the number of steps taken to get to the position string
// from the original
struct data {
char* position;
char* from;
int steps;
};
typedef struct data Data;
typedef struct node hashNode; // array of data structs is a node in hash
typedef hashNode* Table;
// a hash function that generates a hash index based on the string
// and the table size
// this hash function was borrowed from Stanley Eisenstat of Yale University
long hash (char *s, long size);
// a function that creates a hash table using the size as a way of
// determining how big the hash table will be (how many indexes it has)
Table createTable(long size);
// add a triple (string position, string from, string)
void insert(Table table, long size, Data* triple);
Data* search(Table table, long size, char* key);
char* searchPos(Table table, long size, char* key);
char* searchFrom(Table table, long size, char* key);
int searchSteps(Table table, long size, char* key);
Table tableResize(Table table, long old_size, long new_size);
void tableDestroy(Table table, long size);
void printTable(Table test, long tableSize);