feisty meow concerns codebase  2.140
structures::hashing_algorithm Class Referenceabstract

A hashing algorithm takes a key and derives a related integer from it. More...

#include <hash_table.h>

Inheritance diagram for structures::hashing_algorithm:
Collaboration diagram for structures::hashing_algorithm:

Public Member Functions

virtual basis::un_int hash (const void *key_data, int key_length) const =0
 returns a hash value based on the "key_data" and "key_length". More...
 
virtual hashing_algorithmclone () const =0
 supports virtual construction of new algorithm objects. More...
 

Detailed Description

A hashing algorithm takes a key and derives a related integer from it.

The hashing_algorithm is used in hash_tables for placing objects into slots that can be easily found again. The numerical hash should be faster than actually doing a search on what might be unsorted data otherwise.

Definition at line 40 of file hash_table.h.

Member Function Documentation

◆ clone()

virtual hashing_algorithm* structures::hashing_algorithm::clone ( ) const
pure virtual

supports virtual construction of new algorithm objects.

Implements basis::clonable.

Implemented in structures::astring_hasher, structures::string_hasher, and structures::rotating_byte_hasher.

◆ hash()

virtual basis::un_int structures::hashing_algorithm::hash ( const void *  key_data,
int  key_length 
) const
pure virtual

returns a hash value based on the "key_data" and "key_length".

the "key_length" is provided from the sizeof() of the key type used in the hash_table (below). it is up to the implementor to create a hash value that spreads the keys to be hashed appropriately. if similar keys create same or similar hash values, then the efficiency of the hash_table is compromised.

Implemented in structures::astring_hasher, structures::string_hasher, and structures::rotating_byte_hasher.


The documentation for this class was generated from the following file: