-
Notifications
You must be signed in to change notification settings - Fork 17
/
hash.h
45 lines (25 loc) · 883 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
41
42
43
44
45
/* HASHING TABLE */
#ifndef __HASH_H
#define __HASH_H
#define TABLE_SIZE 32768 /* size of the hash table (must be power of 2) */
struct table_type{ /* HASH TABLE */
unsigned char count;
struct object_list **pointer;
};
extern struct table_type table[TABLE_SIZE];
/* hash function */
unsigned int hash(unsigned int id);
/* adds object to hash table */
void add_to_table(struct object_list *pointer);
/* removes object from table */
/* returns pointer to the object */
/* if there's not such an object returns null */
struct object_list * remove_from_table(unsigned int id);
/* tests if object is in table */
/* returns pointer to the object, if no returns 0 */
struct object_list *find_in_table(unsigned int id);
/* initializes hash table */
void hash_table_init(void);
/* removes hash table from memory */
void free_hash_table(void);
#endif