Updated project to use eclipse build tools and make system.
[C-Data-Structures.git] / lib_hash.h
blob988176805d6ce37d5ea6b89f647f2670702938a7
1 #ifndef LIB_HASH_H_
2 #define LIB_HASH_H_
4 #define EMPTY 0
6 typedef struct hash {
7 int * data;
8 int size;
9 } Hash;
12 create new hash with len length
13 returns null pointer when hash could not be created.
15 Hash hash_new(int len);
18 same as hash_new accept:
19 tests input length - determine if number is double prime.
20 If not, finds next larger double prime for size of hash.
22 Hash hash_new_prime(int len);
24 /* insert data into hash, must be sent with size of data */
25 int hash_insert(Hash h, void * data, size_t length);
27 /* search hash for data value, return address of data */
28 void * hash_search(Hash h, void * data, size_t length);
30 /* remove data from hash, must be sent with size of data removed */
31 int hash_remove(Hash h, void * data, size_t length);
33 /* test for empty hash - no data stored */
34 int hash_empty(Hash h);
36 /* test for hash that is completely full */
37 int hash_full(Hash h);
39 /* remove all data from hash */
40 void hash_clear(Hash h);
42 /* print hash contents to stdout - used for debugging */
43 void hash_print(Hash h);
45 /* delete hash and all its contents */
46 void hash_delete(Hash h);
48 /* find next double prime number - used for lenth of arrays */
49 int is_prime(int num);
51 /* find next prime number where number-2 is also prime */
52 int next_twinprime(int num);
54 #endif /* LIB_HASH_H_ */