CS::Utility::StringSet< Tag, Locked > Class Template Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
CS::Utility::StringSet< Tag, Locked > Class Template Reference

The string set is a collection of unique strings. More...

`#include <csutil/strset.h>`

List of all members.

## Public Member Functions
void | Clear ()
| Remove all stored strings.
bool | Contains (char const *s) const
| Check if the set contains a particular string.
bool | Contains (CS::StringID< Tag > id) const
| Check if the set contains a string with a particular ID.
bool | Delete (char const *s)
| Remove specified string.
bool | Delete (CS::StringID< Tag > id)
| Remove a string with the specified ID.
void | Empty ()
| Remove all stored strings.
GlobalIterator | GetIterator () const
| Return an iterator for the set which iterates over all strings.
size_t | GetSize () const
| Get the number of elements in the hash.
bool | IsEmpty () const
| Return true if the hash is empty.
StringSet & | operator= (StringSet const &s)
| Assignment operator.
CS::StringID< Tag > | Request (const char *s)
| Request the numeric ID for the given string.
char const * | Request (CS::StringID< Tag > id) const
| Request the string corresponding to the given ID.
| StringSet (size_t size=23)
| Constructor.
| StringSet (StringSet const &s)
| Copy constructor.
| ~StringSet ()
| Destructor.

## Detailed Description

### template<typename Tag, bool Locked = false>
class CS::Utility::StringSet< Tag, Locked >

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.

If Locked is true operations on an instance of the set are locked are for concurrent accesses.

See also:
  csStringHash
  iStringSet

Definition at line 48 of file strset.h.

## Constructor & Destructor Documentation

template<typename Tag, bool Locked = false>

CS::Utility::StringSet< Tag, Locked >::StringSet | ( | size_t | size = `23` | ) | `[inline]`

Constructor.

Definition at line 81 of file strset.h.

template<typename Tag, bool Locked = false>

CS::Utility::StringSet< Tag, Locked >::StringSet | ( | StringSet< Tag, Locked > const & | s | ) | `[inline]`

Copy constructor.

Definition at line 83 of file strset.h.

template<typename Tag, bool Locked = false>

CS::Utility::StringSet< Tag, Locked >::~StringSet | ( |  | ) | `[inline]`

Destructor.

Definition at line 85 of file strset.h.

## Member Function Documentation

template<typename Tag, bool Locked = false>

void CS::Utility::StringSet< Tag, Locked >::Clear | ( |  | ) | `[inline]`

Remove all stored strings.

Deprecated:
  Deprecated in 1.3. Use Empty() instead.

Definition at line 189 of file strset.h.

template<typename Tag, bool Locked = false>

bool CS::Utility::StringSet< Tag, Locked >::Contains | ( | char const * | s | ) | const`[inline]`

Check if the set contains a particular string.

Definition at line 122 of file strset.h.

template<typename Tag, bool Locked = false>

bool CS::Utility::StringSet< Tag, Locked >::Contains | ( | CS::StringID< Tag > | id | ) | const`[inline]`

Check if the set contains a string with a particular ID.

Remarks:
  This is rigidly equivalent to `return Request(id) != NULL`, but more idomatic.

Definition at line 133 of file strset.h.

template<typename Tag, bool Locked = false>

bool CS::Utility::StringSet< Tag, Locked >::Delete | ( | char const * | s | ) | `[inline]`

Remove specified string.

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

Definition at line 143 of file strset.h.

template<typename Tag, bool Locked = false>

bool CS::Utility::StringSet< Tag, Locked >::Delete | ( | CS::StringID< Tag > | id | ) | `[inline]`

Remove a string with the specified ID.

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

Definition at line 160 of file strset.h.

template<typename Tag, bool Locked = false>

void CS::Utility::StringSet< Tag, Locked >::Empty | ( |  | ) | `[inline]`

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.

Definition at line 177 of file strset.h.

template<typename Tag, bool Locked = false>

GlobalIterator CS::Utility::StringSet< Tag, Locked >::GetIterator | ( |  | ) | const`[inline]`

Return an iterator for the set which iterates over all strings.

Warning:
  Modifying the set while you have open iterators will result undefined behaviour.
  The iterator will not respect locking of the string set!

Definition at line 216 of file strset.h.

template<typename Tag, bool Locked = false>

size_t CS::Utility::StringSet< Tag, Locked >::GetSize | ( |  | ) | const`[inline]`

Get the number of elements in the hash.

Definition at line 193 of file strset.h.

template<typename Tag, bool Locked = false>

bool CS::Utility::StringSet< Tag, Locked >::IsEmpty | ( |  | ) | const`[inline]`

Return true if the hash is empty.

Remarks:
  Rigidly equivalent to `return GetSize() == 0`, but more idiomatic.

Definition at line 204 of file strset.h.

template<typename Tag, bool Locked = false>

StringSet& CS::Utility::StringSet< Tag, Locked >::operator= | ( | StringSet< Tag, Locked > const & | s | ) | `[inline]`

Assignment operator.

Definition at line 87 of file strset.h.

template<typename Tag, bool Locked = false>

CS::StringID<Tag> CS::Utility::StringSet< Tag, Locked >::Request | ( | const char * | s | ) | `[inline]`

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.

Definition at line 95 of file strset.h.

template<typename Tag, bool Locked = false>

char const* CS::Utility::StringSet< Tag, Locked >::Request | ( | CS::StringID< Tag > | id | ) | const`[inline]`

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.

Definition at line 113 of file strset.h.

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

- csutil/strset.h