#include <stringhash.h>
Public Member Functions | |
StringHash () | |
Constructor. | |
virtual | ~StringHash () |
unsigned | hash (const char *s) |
Hashes a string value. | |
unsigned | hash (const char *s, unsigned start_offset, unsigned end_offset) |
Hashes a string value. | |
Private Member Functions | |
unsigned | h (const char *s) |
Internal hash function. | |
unsigned | h (const char *s, unsigned start_offset, unsigned end_offset) |
Internal hash function, to hash a substring of the passed string. | |
Private Attributes | |
int | base |
The hash base. | |
vector< TagInfo * > * | matches |
Hashed values. | |
unsigned | free_index |
The next available free index position. |
Implements a simple yet efficient string hash function.
Definition at line 94 of file stringhash.h.
StringHash::StringHash | ( | ) |
Constructor.
Constructor - creating object.
Definition at line 39 of file stringhash.cpp.
References hash().
StringHash::~StringHash | ( | ) | [virtual] |
unsigned StringHash::h | ( | const char * | s, | |
unsigned | start_offset, | |||
unsigned | end_offset | |||
) | [private] |
Internal hash function, to hash a substring of the passed string.
The hash function sums up the substring character values and divides the result through the specified base.
[in] | s | The string to be hashed. |
[in] | start_offset | The start offset position inside the string. |
[in] | end_offset | The end offsetposition inside the string. |
unsigned | The hash value. |
Definition at line 108 of file stringhash.cpp.
References base.
unsigned StringHash::h | ( | const char * | s | ) | [private] |
Internal hash function.
The hash function sums up the character values and divides the result through the specified base.
[in] | s | The string to be hashed. |
unsigned | The hash value. |
Definition at line 97 of file stringhash.cpp.
References base.
Referenced by hash().
unsigned StringHash::hash | ( | const char * | s, | |
unsigned | start_offset, | |||
unsigned | end_offset | |||
) |
Hashes a string value.
Hashes a substring of the passed string value.
[in] | s | The string to be hashed. |
[in] | start_offset | The start offset position inside the string. |
[in] | end_offset | The end offsetposition inside the string. |
unsigned | The hash value. |
Definition at line 73 of file stringhash.cpp.
References free_index, h(), and matches.
unsigned StringHash::hash | ( | const char * | s | ) |
Hashes a string value.
Hashes a complete string value, i.e. computes the hash value of the string.
[in] | s | The string to be hashed. |
unsigned | The hash value. |
Definition at line 54 of file stringhash.cpp.
References free_index, h(), and matches.
Referenced by TagMap::insertTag(), TagMap::insertTagWithOffset(), and StringHash().
int StringHash::base [private] |
The hash base.
The hash base, initialized with valur HASH_BASE (which should always be set to a prime number).
Definition at line 151 of file stringhash.h.
Referenced by h(), and ~StringHash().
unsigned StringHash::free_index [private] |
The next available free index position.
The next available free index position in member matches.
Definition at line 164 of file stringhash.h.
Referenced by hash().
vector< TagInfo * > * StringHash::matches [private] |
Hashed values.
The buckets containing previous matches computed by the hash function.
Definition at line 158 of file stringhash.h.
Referenced by hash(), and ~StringHash().