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 (csStringHashReversible const &h)
 Copy constructor.
 csStringHashReversible (size_t size=23)
 Constructor.
bool Delete (csStringID id)
 Remove a string with the specified ID.
bool Delete (char const *s)
 Remove specified string.
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.
csArray< const char * > RequestAll (csStringID id) const
 Request all strings for a given ID.
 ~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 ( 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).
bool csStringHashReversible::Delete ( char const *  s  ) 

Remove specified string.

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

Reimplemented from CS::Utility::StringHash< Tag >.

void csStringHashReversible::Empty (  ) 

Remove all stored strings.

Reimplemented from CS::Utility::StringHash< Tag >.

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

Assignment operator.

Reimplemented from CS::Utility::StringHash< Tag >.

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.
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).
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 CS::Utility::StringHash< Tag >.

Definition at line 71 of file strhashr.h.

csArray<const char*> csStringHashReversible::RequestAll ( csStringID  id  )  const [inline]

Request all strings for a given ID.

Returns:
Array of all the elements, or empty if there are none.

Definition at line 86 of file strhashr.h.


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

Generated for Crystal Space 2.0 by doxygen 1.6.1