## Public API Reference

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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csSet< T > Class Template Reference
[Containers]

This class implements a basic set for objects. More...

`#include <csutil/set.h>`

List of all members.

## Public Types

typedef csHash< bool, T > | HashType

## Public Member Functions

void | Add (const T &object)
| Add an object to this set.
void | AddNoTest (const T &object)
| Add an object to this set.
bool | Contains (const T &object) const
| Test if an object is in this set.
| csSet (int size=23, int grow_rate=5, int max_size=20000)
| Construct a new empty set.
bool | Delete (const T &object)
| Delete an object from the set.
void | DeleteAll ()
| Delete all elements in the set.
void | Empty ()
| Delete all elements in the set. (Idiomatic alias for DeleteAll().).
GlobalIterator | GetIterator () const
| Return an iterator for the set which iterates over all elements.
size_t | GetSize () const
| Get the number of elements in the set.
bool | In (const T &object) const
| Test if an object is in this set.
bool | IsEmpty () const
| Return true if the set is empty.

## Friends

class | GlobalIterator

## Classes

class | GlobalIterator
| An iterator class for the set. More...

## Detailed Description

### template<class T>
class csSet< T >

This class implements a basic set for objects.

You can basically use this to test for the occurrence of some object quickly.

Definition at line 37 of file set.h.

## Constructor & Destructor Documentation

template<class T>
csSet< T >::csSet | ( | int | size = `23`,
|  | int | grow_rate = `5`,
|  | int | max_size = `20000`
| ) | `[inline]`

| Construct a new empty set. size, grow_rate, and max_size allow fine-tuning of how the set manages its internal allocations. Definition at line 82 of file set.h.

## Member Function Documentation

template<class T>
void csSet< T >::Add | ( | const T & | object | ) | `[inline]`

| Add an object to this set. This will do nothing if the object is already present. Definition at line 91 of file set.h.

template<class T>
void csSet< T >::AddNoTest | ( | const T & | object | ) | `[inline]`

| Add an object to this set. This function does not test if the object is already there. This is used for efficiency reasons. But use with care! Definition at line 103 of file set.h. Referenced by csSet< csPtrKey< KnownFont > >::Add().

template<class T>
bool csSet< T >::Contains | ( | const T & | object | ) | const`[inline]`

| Test if an object is in this set. Definition at line 111 of file set.h. Referenced by csSet< csPtrKey< KnownFont > >::Add(), and csSet< csPtrKey< KnownFont > >::In().

template<class T>
bool csSet< T >::Delete | ( | const T & | object | ) | `[inline]`

| Delete an object from the set. This function does nothing if the object is not in the set. Return true if the object was present. Definition at line 140 of file set.h.

template<class T>
void csSet< T >::DeleteAll | ( |  | ) | `[inline]`

| Delete all elements in the set. Definition at line 127 of file set.h. Referenced by csSet< csPtrKey< KnownFont > >::Empty().

template<class T>
void csSet< T >::Empty | ( |  | ) | `[inline]`

| Delete all elements in the set. (Idiomatic alias for DeleteAll().). Definition at line 133 of file set.h.

template<class T>
GlobalIterator csSet< T >::GetIterator | ( |  | ) | const`[inline]`

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

Warning:
  Modifying the set while you have open iterators will cause undefined behaviour.

Definition at line 166 of file set.h.

template<class T>
size_t csSet< T >::GetSize | ( |  | ) | const`[inline]`

| Get the number of elements in the set. Definition at line 146 of file set.h. Referenced by csSet< csPtrKey< KnownFont > >::IsEmpty().

template<class T>
bool csSet< T >::In | ( | const T & | object | ) | const`[inline]`

Test if an object is in this set.

Remarks:
  This is rigidly equivalent to Contains(object), but may be considered more idiomatic by some.

Definition at line 121 of file set.h.

template<class T>
bool csSet< T >::IsEmpty | ( |  | ) | const`[inline]`

Return true if the set is empty.

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

Definition at line 156 of file set.h.

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

- csutil/set.h