| Nebula
							 | 
#include <set.h>
A collection of unique values with quick lookup.
Internally implemented as a sorted array.
Adding the same value more than once has no obvious effect.
On insertion performance: Key/value pairs are inserted with the Add() method, which normally calls the Util::Array::InsertSorted() method internally. If many insertions are performed at once, it may be beneficial to call BeginBulkAdd() before, and EndBulkAdd() after adding the key/value pairs. Between BeginBulkAdd() and EndBulkAdd(), the Add() method will just append the new elements to the internal array, and only call Util::Array::Sort() inside EndBulkAdd().
Any methods which require the internal array to be sorted will throw an assertion between BeginBulkAdd() and EndBulkAdd().
| Public Member Functions | |
| Set () | |
| default constructor | |
| Set (const Set< KEYTYPE > &rhs) | |
| copy constructor | |
| void | operator= (const Set< KEYTYPE > &rhs) | 
| assignment operator | |
| SizeT | Size () const | 
| return number of unique keys | |
| void | Clear () | 
| clear the set | |
| bool | IsEmpty () const | 
| return true if empty | |
| void | Reserve (SizeT numElements) | 
| reserve space (useful if number of elements is known beforehand) | |
| void | Add (const KEYTYPE &value) | 
| add a unique value to set, won't get added twice | |
| void | Erase (const KEYTYPE &key) | 
| erase a key and its associated value | |
| void | EraseAtIndex (IndexT index) | 
| erase a key at index | |
| IndexT | FindIndex (const KEYTYPE &key) const | 
| find index of key pair (InvalidIndex if doesn't exist) | |
| bool | Contains (const KEYTYPE &key) const | 
| return true if key exists in the array | |
| const KEYTYPE & | KeyAtIndex (IndexT index) const | 
| get a key at given index | |
| const Array< KEYTYPE > & | KeysAsArray () const | 
| get all keys as an Util::Array | |
| template<class RETURNTYPE> | |
| RETURNTYPE | KeysAs () const | 
| get all keys as (typically) an array | |
| Protected Member Functions | |
| void | SortIfDirty () const | 
| make sure the key value pair array is sorted | |
| Protected Attributes | |
| Array< KEYTYPE > | values | 
| Util::Set< KEYTYPE >::Set | ( | ) | 
default constructor
| void Util::Set< KEYTYPE >::Add | ( | const KEYTYPE & | value | ) | 
add a unique value to set, won't get added twice
| void Util::Set< KEYTYPE >::Clear | ( | ) | 
clear the set
| bool Util::Set< KEYTYPE >::Contains | ( | const KEYTYPE & | key | ) | const | 
return true if key exists in the array
| void Util::Set< KEYTYPE >::Erase | ( | const KEYTYPE & | key | ) | 
erase a key and its associated value
erase a key at index
find index of key pair (InvalidIndex if doesn't exist)
| bool Util::Set< KEYTYPE >::IsEmpty | ( | ) | const | 
return true if empty
get a key at given index
| RETURNTYPE Util::Set< KEYTYPE >::KeysAs | ( | ) | const | 
get all keys as (typically) an array
get all keys as an Util::Array
assignment operator
reserve space (useful if number of elements is known beforehand)
| 
 | protected | 
make sure the key value pair array is sorted