CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csStringHash Class Reference

A string-to-ID hash table. More...

#include <strhash.h>

List of all members.

Public Methods

 csStringHash (uint32 size=211)
 Constructor.

 ~csStringHash ()
 Destructor.

const char * Register (const char *s, csStringID id)
 Register a string with an ID.

csStringID Request (const char *s)
 Request the ID for the given string.

const char * Request (csStringID id)
 Request the string for a given ID.

void Clear ()
 Delete all stored strings.


Detailed Description

A string-to-ID hash table.

Useful when you need to work with strings but want the performance characteristics of simple numeric comparisons. Register a string with a unique numeric ID and then compare ID's rather than comparing strings. You can fetch a string's ID via Request().

See also:
csStringSet

Definition at line 75 of file strhash.h.


Constructor & Destructor Documentation

csStringHash::csStringHash uint32    size = 211
 

Constructor.

csStringHash::~csStringHash  
 

Destructor.


Member Function Documentation

void csStringHash::Clear  
 

Delete all stored strings.

const char* csStringHash::Register const char *    s,
csStringID    id
 

Register a string with an ID.

Parameters:
s  The string with which to associate the ID.
id  A numeric value with which to identify this string.
Returns:
A pointer to the copy of the string in this hash.
Remarks:
If the string is already registered with a different ID, the old ID will be replaced with the one specified here. If you would like the convenience of having the ID assigned automatically, then consider using csStringSet, instead.

const char* csStringHash::Request csStringID    id
 

Request the string for a given ID.

Returns:
The string associated with the given ID, or the null pointer if the string has not yet been registered.
Remarks:
This operation is relatively slow. If you find that you must perform this reverse lookup frequently, then consider using csStringSet, instead.

csStringID csStringHash::Request const char *    s
 

Request the ID for the given string.

Returns:
The string's ID or csInvalidStringID if the string has not yet been registered.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18