iStringSetBase< Tag > Struct Template Reference
[Utilities]
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 (CS::StringID< Tag >) const =0 |
Check if the set contains a string with a particular ID. | |
virtual bool | Contains (char const *) const =0 |
Check if the set contains a particular string. | |
virtual bool | Delete (CS::StringID< Tag >)=0 |
Remove a string with the specified ID. | |
virtual bool | Delete (char const *)=0 |
Remove specified string. | |
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 const char * | Request (CS::StringID< Tag >) const =0 |
Request the string corresponding to the given ID. | |
virtual CS::StringID< Tag > | Request (const char *)=0 |
Request the numeric ID for the given string. |
Detailed Description
template<typename Tag>
struct iStringSetBase< Tag >
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");
- See also:
- csStringHash
- csStringSet
Definition at line 114 of file strset.h.
Member Function Documentation
virtual void iStringSetBase< Tag >::Clear | ( | ) | [pure virtual] |
Remove all stored strings.
- Deprecated:
- Deprecated in 1.3. Use Empty() instead.
virtual bool iStringSetBase< Tag >::Contains | ( | CS::StringID< Tag > | ) | const [pure virtual] |
Check if the set contains a string with a particular ID.
- Remarks:
- This is rigidly equivalent to
return Request(id) != NULL
, but more idiomatic.
virtual bool iStringSetBase< Tag >::Contains | ( | char const * | ) | const [pure virtual] |
Check if the set contains a particular string.
virtual bool iStringSetBase< Tag >::Delete | ( | CS::StringID< Tag > | ) | [pure virtual] |
Remove a string with the specified ID.
- Returns:
- True if a matching string was in the set; else false.
virtual bool iStringSetBase< Tag >::Delete | ( | char const * | ) | [pure virtual] |
Remove specified string.
- Returns:
- True if a matching string was in thet set; else false.
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.
- Remarks:
- Rigidly equivalent to
return GetSize() == 0
, but more idiomatic.
virtual const char* iStringSetBase< Tag >::Request | ( | CS::StringID< Tag > | ) | const [pure virtual] |
Request the string corresponding to the given ID.
- Returns:
- Null if the string * has not been requested (yet), else the string corresponding to the ID.
virtual CS::StringID<Tag> iStringSetBase< Tag >::Request | ( | const char * | ) | [pure virtual] |
Request the numeric ID for the given string.
- Returns:
- The ID of the string.
- Remarks:
- Creates a new ID if the string is not yet present in the set, else returns the previously assigned ID.
The documentation for this struct was generated from the following file:
- iutil/strset.h
Generated for Crystal Space 2.0 by doxygen 1.6.1