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.

Classes

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

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.
void Subtract (const csSet &otherSet)
 Subtract a set from this set and put the result in this set.
bool TestIntersect (const csSet &other) const
 Test if this set intersects with another set (i.e.
void Union (const csSet &otherSet)
 Calculate the union of two sets and put the result in this set.

Friends

csSet Intersect (const csSet &s1, const csSet &s2)
 Calculate the intersection of two sets and put the result in a new set.
csSet Subtract (const csSet &s1, const csSet &s2)
 Subtract two sets and return the result in a new set.
csSet Union (const csSet &s1, const csSet &s2)
 Calculate the union of two sets and put the result in a new set.

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.

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.

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.

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 251 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 231 of file set.h.

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 241 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::Subtract ( const csSet< T, Allocator > &  otherSet  )  [inline]

Subtract a set from this set and put the result in this set.

Definition at line 207 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
bool csSet< T, Allocator >::TestIntersect ( const csSet< T, Allocator > &  other  )  const [inline]

Test if this set intersects with another set (i.e.

they have common elements).

Definition at line 171 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
void csSet< T, Allocator >::Union ( const csSet< T, Allocator > &  otherSet  )  [inline]

Calculate the union of two sets and put the result in this set.

Definition at line 149 of file set.h.


Friends And Related Function Documentation

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
csSet Intersect ( const csSet< T, Allocator > &  s1,
const csSet< T, Allocator > &  s2 
) [friend]

Calculate the intersection of two sets and put the result in a new set.

Definition at line 191 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
csSet Subtract ( const csSet< T, Allocator > &  s1,
const csSet< T, Allocator > &  s2 
) [friend]

Subtract two sets and return the result in a new set.

Definition at line 217 of file set.h.

template<class T, class Allocator = CS::Memory::AllocatorMalloc>
csSet Union ( const csSet< T, Allocator > &  s1,
const csSet< T, Allocator > &  s2 
) [friend]

Calculate the union of two sets and put the result in a new set.

Definition at line 160 of file set.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1