StringHash Class Reference

Represents a string hash function. More...

#include <stringhash.h>

Collaboration diagram for StringHash:

Collaboration graph
[legend]

List of all members.

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.


Detailed Description

Represents a string hash function.

Implements a simple yet efficient string hash function.

Author:
Michael Schmidt

Gunnar Jehl

Version:
2.1
License:
Software License Agreement (BSD License)

Definition at line 94 of file stringhash.h.


Constructor & Destructor Documentation

StringHash::StringHash (  ) 

Constructor.

Constructor - creating object.

Definition at line 39 of file stringhash.cpp.

References hash().

StringHash::~StringHash (  )  [virtual]

Destructor.

Definition at line 44 of file stringhash.cpp.

References base, and matches.


Member Function Documentation

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.

Parameters:
[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.
Return values:
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.

Parameters:
[in] s The string to be hashed.
Return values:
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.

Parameters:
[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.
Return values:
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.

Parameters:
[in] s The string to be hashed.
Return values:
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().


Member Data Documentation

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().


Generated on Sun May 24 20:20:30 2009 for G(arbage) C(ollected) X(Query) Engine by  doxygen 1.5.9