Static list not using dynamic memory allocation. More...
#include <SgArrayList.h>
Classes | |
class | Iterator |
Const iterator. More... | |
class | NonConstIterator |
Non-const iterator. More... | |
Public Member Functions | |
SgArrayList () | |
SgArrayList (const T &val) | |
Construct list with one element. | |
SgArrayList (const SgArrayList< T, SIZE > &list) | |
SgArrayList & | operator= (const SgArrayList &list) |
bool | operator== (const SgArrayList &list) const |
bool | operator!= (const SgArrayList &list) const |
T & | operator[] (int index) |
const T & | operator[] (int index) const |
void | Clear () |
bool | Contains (const T &val) const |
bool | Exclude (const T &val) |
Remove first occurrence of a value. | |
void | Include (const T &val) |
PushBack value at the end of the list if it's not already in the list. | |
SgArrayList | Intersect (const SgArrayList< T, SIZE > &list) const |
Build intersection with other list. | |
bool | IsEmpty () const |
T & | Last () |
const T & | Last () const |
int | Length () const |
void | PopBack () |
Remove the last element of the list. | |
void | PushBack (const T &val) |
template<int SIZE2> | |
void | PushBackList (const SgArrayList< T, SIZE2 > &list) |
Push back all elements of another list. | |
void | RemoveFirst (const T &val) |
Remove first occurence of a value. | |
void | Resize (int length) |
Resize list. | |
bool | SameElements (const SgArrayList &list) const |
void | SetTo (const T &val) |
void | Sort () |
Private Attributes | |
int | m_len |
T | m_array [SIZE] |
Friends | |
class | Iterator |
class | NonConstIterator |
Static list not using dynamic memory allocation.
Elements need to have a default constructor. They should be value-types, not entity-types, because operations like Clear() do not call the destructor of the old elements immediately.
Definition at line 18 of file SgArrayList.h.
SgArrayList< T, SIZE >::SgArrayList | ( | ) |
Definition at line 199 of file SgArrayList.h.
SgArrayList< T, SIZE >::SgArrayList | ( | const T & | val | ) | [explicit] |
Construct list with one element.
Definition at line 205 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SgArrayList< T, SIZE >::SetTo().
SgArrayList< T, SIZE >::SgArrayList | ( | const SgArrayList< T, SIZE > & | list | ) |
Definition at line 213 of file SgArrayList.h.
void SgArrayList< T, SIZE >::Clear | ( | ) |
Definition at line 265 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_len.
bool SgArrayList< T, SIZE >::Contains | ( | const T & | val | ) | const |
Definition at line 271 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
Referenced by SgArrayList< T, SIZE >::Include(), SgArrayList< T, SIZE >::Intersect(), and SgArrayList< T, SIZE >::SameElements().
bool SgArrayList< T, SIZE >::Exclude | ( | const T & | val | ) |
Remove first occurrence of a value.
Like RemoveFirst, but more efficient and does not preserve order of remaining elements. The first occurrence of the value is replaced by the last element.
Definition at line 282 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
void SgArrayList< T, SIZE >::Include | ( | const T & | val | ) |
PushBack value at the end of the list if it's not already in the list.
Definition at line 299 of file SgArrayList.h.
References SgArrayList< T, SIZE >::Contains(), and SgArrayList< T, SIZE >::PushBack().
SgArrayList< T, SIZE > SgArrayList< T, SIZE >::Intersect | ( | const SgArrayList< T, SIZE > & | list | ) | const |
Build intersection with other list.
List may not contain duplicate entries.
Definition at line 307 of file SgArrayList.h.
References SgArrayList< T, SIZE >::Contains(), SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, SgArrayList< T, SIZE >::PushBack(), and SG_ASSERT.
bool SgArrayList< T, SIZE >::IsEmpty | ( | ) | const |
Definition at line 321 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_len.
T & SgArrayList< T, SIZE >::Last | ( | ) |
Definition at line 327 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
const T & SgArrayList< T, SIZE >::Last | ( | ) | const |
Definition at line 334 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
int SgArrayList< T, SIZE >::Length | ( | ) | const |
Definition at line 341 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_len.
bool SgArrayList< T, SIZE >::operator!= | ( | const SgArrayList< T, SIZE > & | list | ) | const |
Definition at line 243 of file SgArrayList.h.
References SgArrayList< T, SIZE >::operator==().
SgArrayList< T, SIZE > & SgArrayList< T, SIZE >::operator= | ( | const SgArrayList< T, SIZE > & | list | ) |
Definition at line 219 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
bool SgArrayList< T, SIZE >::operator== | ( | const SgArrayList< T, SIZE > & | list | ) | const |
Definition at line 230 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
Referenced by SgArrayList< T, SIZE >::operator!=().
T & SgArrayList< T, SIZE >::operator[] | ( | int | index | ) |
Definition at line 249 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
const T & SgArrayList< T, SIZE >::operator[] | ( | int | index | ) | const |
Definition at line 257 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
void SgArrayList< T, SIZE >::PopBack | ( | ) |
Remove the last element of the list.
Does not return the last element for efficiency. To get the last element, use Last() before calling PopBack().
Definition at line 347 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
void SgArrayList< T, SIZE >::PushBack | ( | const T & | val | ) |
Definition at line 354 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
Referenced by SgArrayList< T, SIZE >::Include(), SgArrayList< T, SIZE >::Intersect(), and SgArrayList< T, SIZE >::PushBackList().
void SgArrayList< T, SIZE >::PushBackList | ( | const SgArrayList< T, SIZE2 > & | list | ) |
Push back all elements of another list.
Works with lists of different maximum sizes. Requires: Total resulting number of elements will fit into the target list.
Definition at line 362 of file SgArrayList.h.
References SgArrayList< T, SIZE >::PushBack().
void SgArrayList< T, SIZE >::RemoveFirst | ( | const T & | val | ) |
Remove first occurence of a value.
Preserves order of remaining elements.
Definition at line 369 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
void SgArrayList< T, SIZE >::Resize | ( | int | length | ) |
Resize list.
If new length is greater than current length, then the elements at a place greater than the old length are not initialized, they are just the old elements at this place. This is necessary if elements are re-used for efficiency and will be initialized later.
Definition at line 384 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_len, and SG_ASSERT.
bool SgArrayList< T, SIZE >::SameElements | ( | const SgArrayList< T, SIZE > & | list | ) | const |
Definition at line 392 of file SgArrayList.h.
References SgArrayList< T, SIZE >::Contains(), SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
void SgArrayList< T, SIZE >::SetTo | ( | const T & | val | ) |
Definition at line 404 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
Referenced by SgArrayList< T, SIZE >::SgArrayList().
void SgArrayList< T, SIZE >::Sort | ( | ) |
Definition at line 411 of file SgArrayList.h.
References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.
friend class Iterator [friend] |
Definition at line 135 of file SgArrayList.h.
friend class NonConstIterator [friend] |
Definition at line 136 of file SgArrayList.h.
T SgArrayList< T, SIZE >::m_array[SIZE] [private] |
Definition at line 140 of file SgArrayList.h.
Referenced by SgArrayList< T, SIZE >::Contains(), SgArrayList< T, SIZE >::Exclude(), SgArrayList< T, SIZE >::Intersect(), SgArrayList< T, SIZE >::Last(), SgArrayList< T, SIZE >::operator=(), SgArrayList< T, SIZE >::operator==(), SgArrayList< T, SIZE >::operator[](), SgArrayList< T, SIZE >::PushBack(), SgArrayList< T, SIZE >::RemoveFirst(), SgArrayList< T, SIZE >::SameElements(), SgArrayList< T, SIZE >::SetTo(), SgArrayList< T, SIZE >::SgArrayList(), and SgArrayList< T, SIZE >::Sort().
int SgArrayList< T, SIZE >::m_len [private] |
Definition at line 138 of file SgArrayList.h.
Referenced by SgArrayList< T, SIZE >::Clear(), SgArrayList< T, SIZE >::Contains(), SgArrayList< T, SIZE >::Exclude(), SgArrayList< T, SIZE >::Intersect(), SgArrayList< T, SIZE >::IsEmpty(), SgArrayList< T, SIZE >::Last(), SgArrayList< T, SIZE >::Length(), SgArrayList< T, SIZE >::operator=(), SgArrayList< T, SIZE >::operator==(), SgArrayList< T, SIZE >::operator[](), SgArrayList< T, SIZE >::PopBack(), SgArrayList< T, SIZE >::PushBack(), SgArrayList< T, SIZE >::RemoveFirst(), SgArrayList< T, SIZE >::Resize(), SgArrayList< T, SIZE >::SameElements(), SgArrayList< T, SIZE >::SetTo(), SgArrayList< T, SIZE >::SgArrayList(), and SgArrayList< T, SIZE >::Sort().