CrystalSpace

Public API Reference

csSet< T, Allocator > 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, Allocator > 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 Allocator = CS::Memory::AllocatorMalloc>
class csSet< T, Allocator >

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, class Allocator = CS::Memory::AllocatorMalloc>
csSet< T, Allocator >::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, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::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, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::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< iMeshWrapper > >::Add().

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
bool csSet< T, Allocator >::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< iMeshWrapper > >::Add(), and csSet< csPtrKey< iMeshWrapper > >::In().

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
bool csSet< T, Allocator >::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, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::DeleteAll (  )  [inline]

Delete all elements in the set.

Definition at line 127 of file set.h.

Referenced by csSet< csPtrKey< iMeshWrapper > >::Empty().

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::Empty (  )  [inline]

Delete all elements in the set. (Idiomatic alias for DeleteAll().).

Definition at line 133 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
GlobalIterator csSet< T, Allocator >::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, class Allocator = CS::Memory::AllocatorMalloc>
size_t csSet< T, Allocator >::GetSize (  )  const [inline]

Get the number of elements in the set.

Definition at line 146 of file set.h.

Referenced by csSet< csPtrKey< iMeshWrapper > >::IsEmpty().

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
bool csSet< T, Allocator >::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, class Allocator = CS::Memory::AllocatorMalloc>
bool csSet< T, Allocator >::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:
Generated for Crystal Space by doxygen 1.4.7