|
CHashTable 1
|
Internal utility functions for HashTable. More...
Functions | |
| size_t | hash_function (int key, size_t table_size) |
| Hash function using division method. | |
| bool | is_prime (size_t n) |
| Is prime function. | |
| size_t | next_prime (size_t n) |
| Finds the next prime number after n. | |
Internal utility functions for HashTable.
| size_t hash_function | ( | int | key, |
| size_t | table_size | ||
| ) |
Hash function using division method.
The hash is hash = key % table_size. The hash is always positive.
| key | Key to hash |
| table_size | Hash table size |
| bool is_prime | ( | size_t | n | ) |
Is prime function.
Using an optimized trial division method with the 6k ± 1 rule
| size_t next_prime | ( | size_t | n | ) |
Finds the next prime number after n.
Uses the is_prime() function.
| n | The prime is searched after n |