lab_hash
Hellish Hash Tables
 All Classes Namespaces Files Functions Variables Pages
hashes Namespace Reference

hashes namespace: a collection of templated hash functions. More...

Functions

template<>
unsigned int hash (const char &key, int size)
 Specialized hash() function for character keys. More...
 
template<>
unsigned int hash (const std::string &key, int size)
 Specialized hash() function for std::string keys. More...
 
template<>
unsigned int secondary_hash (const char &key, int size)
 Specialized hash function for character keys. More...
 
template<>
unsigned int secondary_hash (const std::string &key, int size)
 Specialized hash function for std::string keys. More...
 
template<class K >
unsigned int hash (const K &key, int size)
 Computes the hash code of a given key (templated), and returns it modulo size for use in HashTable applications. More...
 
template<class K >
unsigned int secondary_hash (const K &key, int size)
 Computes the secondary hash code of a given key (templated), and returns it modulo size for use in HashTable applications. More...
 

Detailed Description

hashes namespace: a collection of templated hash functions.

Author
Chase Geigle
Date
Summer 2012
Author
Jordi Paris Ferrer Fall 2019

Function Documentation

template<>
unsigned int hashes::hash ( const char &  key,
int  size 
)

Specialized hash() function for character keys.

template<>
unsigned int hashes::hash ( const std::string key,
int  size 
)

Specialized hash() function for std::string keys.

template<class K >
unsigned int hashes::hash ( const K &  key,
int  size 
)

Computes the hash code of a given key (templated), and returns it modulo size for use in HashTable applications.

This function must be specialized in order for one of SCHashTable, LPHashTable, or DHHashTable to contain keys of the specialized type.

Parameters
keyThe key to be hashed.
sizeWhat to modulo the hashcode by.
Returns
The hashcode, modulo size for use as a HashTable index.
template<>
unsigned int hashes::secondary_hash ( const char &  key,
int  size 
)

Specialized hash function for character keys.

template<>
unsigned int hashes::secondary_hash ( const std::string key,
int  size 
)

Specialized hash function for std::string keys.

template<class K >
unsigned int hashes::secondary_hash ( const K &  key,
int  size 
)

Computes the secondary hash code of a given key (templated), and returns it modulo size for use in HashTable applications.

This function must be specialized in order for DHHashTable to contain keys of the specialized type.

This function will never return 0

Parameters
keyThe key to be hashed.
sizeWhat to modulo the hashcode by.
Returns
The hashcode, modulo size for use as a HashTable index.