![]() |
Public API Reference |
A string-to-ID hash table. More...
#include <csutil/strhash.h>
Public Member Functions | |
| void | Clear () |
| Delete all stored strings. | |
| bool | Contains (char const *s) const |
| Check if the hash contains a particular string. | |
| bool | Contains (StringID< Tag > id) const |
| Check if the hash contains a string with a particular ID. | |
| bool | Delete (char const *s) |
| Remove specified string. | |
| bool | Delete (StringID< Tag > id) |
| Remove a string with the specified ID. | |
| void | Empty () |
| Remove all stored strings. | |
| GlobalIterator | GetIterator () const |
| Return an iterator for the string hash which iterates over all elements. | |
| size_t | GetSize () const |
| Get the number of elements in the hash. | |
| bool | IsEmpty () const |
| Return true if the hash is empty. | |
| StringHash & | operator= (StringHash const &h) |
| Assignment operator. | |
| const char * | Register (const char *s, StringID< Tag > id=0) |
| Register a string with an ID. | |
| StringID< Tag > | Request (const char *s) const |
| Request the ID for the given string. | |
| const char * | Request (StringID< Tag > id) const |
| Request the string for a given ID. | |
| StringHash (size_t size=23) | |
| Constructor. | |
| StringHash (StringHash const &h) | |
| Copy constructor. | |
| ~StringHash () | |
| Destructor. | |
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().
| CS::Utility::StringHash< Tag >::StringHash | ( | size_t | size = 23 | ) | [inline] |
| CS::Utility::StringHash< Tag >::StringHash | ( | StringHash< Tag > const & | h | ) | [inline] |
| CS::Utility::StringHash< Tag >::~StringHash | ( | ) | [inline] |
| void CS::Utility::StringHash< Tag >::Clear | ( | ) | [inline] |
Delete all stored strings.
| bool CS::Utility::StringHash< Tag >::Contains | ( | char const * | s | ) | const [inline] |
| bool CS::Utility::StringHash< Tag >::Contains | ( | StringID< Tag > | id | ) | const [inline] |
Check if the hash contains a string with a particular ID.
return Request(id) != NULL, but more idiomatic. | bool CS::Utility::StringHash< Tag >::Delete | ( | char const * | s | ) | [inline] |
Remove specified string.
Reimplemented in csStringHashReversible.
| bool CS::Utility::StringHash< Tag >::Delete | ( | StringID< Tag > | id | ) | [inline] |
| void CS::Utility::StringHash< Tag >::Empty | ( | ) | [inline] |
Remove all stored strings.
Reimplemented in csStringHashReversible.
| GlobalIterator CS::Utility::StringHash< Tag >::GetIterator | ( | ) | const [inline] |
| size_t CS::Utility::StringHash< Tag >::GetSize | ( | ) | const [inline] |
| bool CS::Utility::StringHash< Tag >::IsEmpty | ( | ) | const [inline] |
| StringHash& CS::Utility::StringHash< Tag >::operator= | ( | StringHash< Tag > const & | h | ) | [inline] |
| const char* CS::Utility::StringHash< Tag >::Register | ( | const char * | s, |
| StringID< Tag > | id = 0 |
||
| ) | [inline] |
Register a string with an ID.
| s | The string with which to associate the ID. |
| id | A numeric value with which to identify this string. |
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. | StringID<Tag> CS::Utility::StringHash< Tag >::Request | ( | const char * | s | ) | const [inline] |
Request the ID for the given string.
Reimplemented in csStringHashReversible.
| const char* CS::Utility::StringHash< Tag >::Request | ( | StringID< Tag > | id | ) | const [inline] |
Request the string for a given ID.