33template<
class KEYTYPE>
class Set
52 void Add(
const KEYTYPE& value);
66 template<
class RETURNTYPE> RETURNTYPE
KeysAs()
const;
78template<
class KEYTYPE>
87template<
class KEYTYPE>
97template<
class KEYTYPE>
void
100 this->values = rhs.
values;
106template<
class KEYTYPE>
void
109 this->values.
Clear();
115template<
class KEYTYPE>
SizeT
118 return this->values.Size();
124template<
class KEYTYPE>
bool
127 return (0 == this->values.Size());
133template<
class KEYTYPE>
void
136 this->values.Reserve(numElements);
142template<
class KEYTYPE>
void
145 if (!this->Contains(key))
147 this->values.InsertSorted(key);
154template<
class KEYTYPE>
void
157 IndexT eraseIndex = this->values.BinarySearchIndex(key);
158 #if NEBULA_BOUNDSCHECKS
161 this->values.EraseIndex(eraseIndex);
167template<
class KEYTYPE>
void
170 this->values.EraseIndex(index);
176template<
class KEYTYPE>
IndexT
179 return this->values.BinarySearchIndex(key);
185template<
class KEYTYPE>
bool
188 return (
InvalidIndex != this->values.BinarySearchIndex(key));
194template<
class KEYTYPE>
const KEYTYPE&
197 return this->values[index];
203template<
class KEYTYPE>
204template<
class RETURNTYPE>
208 RETURNTYPE result(this->Size(), this->Size());
210 for (i = 0; i < this->values.Size(); i++)
212 result.Append(this->values[i]);
220template<
class KEYTYPE>
Nebula's dynamic array class.
Definition array.h:60
void Clear()
clear array (calls destructors)
Definition array.h:1207
A collection of unique values with quick lookup.
Definition set.h:34
Array< KEYTYPE > values
Definition set.h:72
SizeT Size() const
return number of unique keys
Definition set.h:116
bool IsEmpty() const
return true if empty
Definition set.h:125
Set(const Set< KEYTYPE > &rhs)
copy constructor
Definition set.h:88
void Erase(const KEYTYPE &key)
erase a key and its associated value
Definition set.h:155
bool Contains(const KEYTYPE &key) const
return true if key exists in the array
Definition set.h:186
void Add(const KEYTYPE &value)
add a unique value to set, won't get added twice
Definition set.h:143
void Reserve(SizeT numElements)
reserve space (useful if number of elements is known beforehand)
Definition set.h:134
IndexT FindIndex(const KEYTYPE &key) const
find index of key pair (InvalidIndex if doesn't exist)
Definition set.h:177
void SortIfDirty() const
make sure the key value pair array is sorted
RETURNTYPE KeysAs() const
get all keys as (typically) an array
Definition set.h:206
void EraseAtIndex(IndexT index)
erase a key at index
Definition set.h:168
Set()
default constructor
Definition set.h:79
void Clear()
clear the set
Definition set.h:107
const Array< KEYTYPE > & KeysAsArray() const
get all keys as an Util::Array
Definition set.h:222
const KEYTYPE & KeyAtIndex(IndexT index) const
get a key at given index
Definition set.h:195
void operator=(const Set< KEYTYPE > &rhs)
assignment operator
Definition set.h:98
#define n_assert(exp)
Definition debug.h:50
A pinned array is an array which manages its own virtual memory.
Definition String.cs:6
static const int InvalidIndex
Definition types.h:54
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48