CrystalSpace

Public API Reference

csStringHashReversible Class Reference

A csStringHash providing a reverse hash for fast string lookups when given an ID. More...

#include <csutil/strhashr.h>

Inheritance diagram for csStringHashReversible:

List of all members.

Public Member Functions

 csStringHashReversible (size_t size=23)
 Constructor.
 csStringHashReversible (csStringHashReversible const &h)
 Copy constructor.
bool Delete (char const *s)
 Remove specified string.
bool Delete (csStringID id)
 Remove a string with the specified ID.
void Empty ()
 Remove all stored strings.
csStringHashReversibleoperator= (csStringHashReversible const &h)
 Assignment operator.
const char * Register (const char *s, csStringID id=0)
 Register a string with an ID.
const char * Request (csStringID id) const
 Request the string for a given ID.
csStringID Request (const char *s) const
 Request the ID for the given string.
 ~csStringHashReversible ()
 Destructor.

Detailed Description

A csStringHash providing a reverse hash for fast string lookups when given an ID.

Definition at line 29 of file strhashr.h.


Constructor & Destructor Documentation

csStringHashReversible::csStringHashReversible ( size_t  size = 23  ) 

Constructor.

csStringHashReversible::csStringHashReversible ( csStringHashReversible const &  h  )  [inline]

Copy constructor.

Definition at line 39 of file strhashr.h.

csStringHashReversible::~csStringHashReversible (  ) 

Destructor.


Member Function Documentation

bool csStringHashReversible::Delete ( char const *  s  ) 

Remove specified string.

Returns:
True if a matching string was in thet set; else false.

Reimplemented from csStringHash.

bool csStringHashReversible::Delete ( csStringID  id  ) 

Remove a string with the specified ID.

Returns:
True if a matching string was in thet set; else false.
Remarks:
If more than one string is associated with the ID, then one is removed (but specifically which one is unspecified).

Reimplemented from csStringHash.

void csStringHashReversible::Empty (  ) 

Remove all stored strings.

Reimplemented from csStringHash.

csStringHashReversible& csStringHashReversible::operator= ( csStringHashReversible const &  h  )  [inline]

Assignment operator.

Definition at line 43 of file strhashr.h.

const char* csStringHashReversible::Register ( const char *  s,
csStringID  id = 0 
)

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.
If you do not care about the ID, but instead simply want to use the hash as a string set which merely records if a string is present, then you can omit id. To find out if a string is contained in the set, invoke Contains(). The same functionality can be accomplished via csStringSet, however csStringSet is more heavyweight because it also maintains a reverse-mapping from ID to string. Omitting the id makes for a good alternative to csStringSet when you do not require its extra bulk.

Reimplemented from csStringHash.

csStringID csStringHashReversible::Request ( const char *  s  )  const [inline]

Request the ID for the given string.

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

Reimplemented from csStringHash.

Definition at line 71 of file strhashr.h.

const char* csStringHashReversible::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. If more than one string is associated with the ID, then one is returned (but specifically which one is unspecified).

Reimplemented from csStringHash.


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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1