![]() |
Public API Reference |
![]() |
The string set is a collection of unique strings. More...
#include <iutil/strset.h>
Public Member Functions | |
virtual void | Clear ()=0 |
Remove all stored strings. | |
virtual bool | Contains (char const *) const =0 |
Check if the set contains a particular string. | |
virtual bool | Contains (CS::StringID< Tag >) const =0 |
Check if the set contains a string with a particular ID. | |
virtual bool | Delete (char const *)=0 |
Remove specified string. | |
virtual bool | Delete (CS::StringID< Tag >)=0 |
Remove a string with the specified ID. | |
virtual void | Empty ()=0 |
Remove all stored strings. | |
virtual size_t | GetSize () const =0 |
Get the number of elements in the hash. | |
virtual bool | IsEmpty () const =0 |
Return true if the hash is empty. | |
virtual CS::StringID< Tag > | Request (const char *)=0 |
Request the numeric ID for the given string. | |
virtual const char * | Request (CS::StringID< Tag >) const =0 |
Request the string corresponding to the given ID. |
The string set is a collection of unique strings.
Each string has an ID number. The most important operation is to request a string, which means to return the ID for the string, adding it to the collection if not already present. This is useful when you need to work with strings but want the performance characteristics of simple numeric comparisons. Rather than performing string comparisons, you instead compare the numeric string ID's.
As a convenience, the csInitializer class creates a string set at application initialization time and inserts it into the global object registry (iObjectRegistry). To obtain a reference this shared string set (which may be desirable when modules need to share string ID's), use a code snippet similar to the following:
iObjectRegistry* object_reg = ...; csRef<iStringSet> strings = csQueryRegistryTagInterface<iStringSet> ( object_reg, "crystalspace.shared.stringset"); csStringID myid = strings->Request ("crystalspace.mygame.mystring");
virtual void iStringSetBase< Tag >::Clear | ( | ) | [pure virtual] |
Remove all stored strings.
virtual bool iStringSetBase< Tag >::Contains | ( | char const * | ) | const [pure virtual] |
Check if the set contains a particular string.
virtual bool iStringSetBase< Tag >::Contains | ( | CS::StringID< Tag > | ) | const [pure virtual] |
Check if the set contains a string with a particular ID.
return Request(id) != NULL
, but more idiomatic. virtual bool iStringSetBase< Tag >::Delete | ( | char const * | ) | [pure virtual] |
Remove specified string.
virtual bool iStringSetBase< Tag >::Delete | ( | CS::StringID< Tag > | ) | [pure virtual] |
Remove a string with the specified ID.
virtual void iStringSetBase< Tag >::Empty | ( | ) | [pure virtual] |
Remove all stored strings.
When new strings are registered again, new ID values will be used; the old ID's will not be re-used.
virtual size_t iStringSetBase< Tag >::GetSize | ( | ) | const [pure virtual] |
Get the number of elements in the hash.
virtual bool iStringSetBase< Tag >::IsEmpty | ( | ) | const [pure virtual] |
Return true if the hash is empty.
return GetSize() == 0
, but more idiomatic. virtual CS::StringID<Tag> iStringSetBase< Tag >::Request | ( | const char * | ) | [pure virtual] |
Request the numeric ID for the given string.
virtual const char* iStringSetBase< Tag >::Request | ( | CS::StringID< Tag > | ) | const [pure virtual] |
Request the string corresponding to the given ID.