CrystalSpace

Public API Reference

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

csStringHash Class Reference

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

#include <csutil/strhash.h>

List of all members.

Public Member Functions

 csStringHash (int size=23)
 Constructor.
 ~csStringHash ()
 Destructor.
const char * Register (const char *s, csStringID id)
 Register a string with an ID.
csStringID Request (const char *s) const
 Request the ID for the given string.
const char * Request (csStringID id) const
 Request the string for a given ID.
void Clear ()
 Delete all stored strings.

Friends

class csStringHashIterator


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 48 of file strhash.h.


Constructor & Destructor Documentation

csStringHash::csStringHash int  size = 23  ) 
 

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  )  const
 

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  )  const
 

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.3.9.1