1 /* HASHING TABLE */ 2 3 #ifndef __HASH_H 4 #define __HASH_H 5 6 #define TABLE_SIZE 32768 /* size of the hash table (must be power of 2) */ 7 8 9 struct table_type{ /* HASH TABLE */ 10 unsigned char count; 11 struct object_list **pointer; 12 }; 13 14 extern struct table_type table[TABLE_SIZE]; 15 16 17 /* hash function */ 18 unsigned int hash(unsigned int id); 19 20 21 /* adds object to hash table */ 22 void add_to_table(struct object_list *pointer); 23 24 25 /* removes object from table */ 26 /* returns pointer to the object */ 27 /* if there's not such an object returns null */ 28 struct object_list * remove_from_table(unsigned int id); 29 30 31 32 /* tests if object is in table */ 33 /* returns pointer to the object, if no returns 0 */ 34 struct object_list *find_in_table(unsigned int id); 35 36 37 /* initializes hash table */ 38 void hash_table_init(void); 39 40 41 /* removes hash table from memory */ 42 void free_hash_table(void); 43 44 45 #endif 46