#include <SgSList.h>
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 20 of file SgSList.h.
Public Member Functions | |
SgSList () | |
SgSList (const T &val) | |
Construct list with one element. | |
SgSList (const SgSList< T, SIZE > &list) | |
SgSList & | operator= (const SgSList &list) |
bool | operator== (const SgSList &list) const |
bool | operator!= (const SgSList &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. | |
SgSList | Intersect (const SgSList< 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 SgSList< 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 SgSList &list) const |
void | SetTo (const T &val) |
void | Sort () |
Private Attributes | |
int | m_len |
T | m_array [SIZE] |
Friends | |
class | Iterator |
class | NonConstIterator |
Classes | |
class | Iterator |
Const iterator. More... | |
class | NonConstIterator |
Non-const iterator. More... |
Construct list with one element.
Definition at line 213 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SgSList< T, SIZE >::SetTo().
void SgSList< T, SIZE >::Clear | ( | ) |
bool SgSList< T, SIZE >::Contains | ( | const T & | val | ) | const |
Definition at line 279 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
Referenced by SgSList< T, SIZE >::Include(), SgSList< T, SIZE >::Intersect(), and SgSList< T, SIZE >::SameElements().
bool SgSList< 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 290 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
void SgSList< 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 307 of file SgSList.h.
References SgSList< T, SIZE >::Contains(), and SgSList< T, SIZE >::PushBack().
SgSList< T, SIZE > SgSList< T, SIZE >::Intersect | ( | const SgSList< T, SIZE > & | list | ) | const |
Build intersection with other list.
List may not contain duplicate entries.
Definition at line 314 of file SgSList.h.
References SgSList< T, SIZE >::Contains(), SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, SgSList< T, SIZE >::PushBack(), and SG_ASSERT.
bool SgSList< T, SIZE >::IsEmpty | ( | ) | const |
const T & SgSList< T, SIZE >::Last | ( | ) | const |
Definition at line 342 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SG_ASSERT.
T & SgSList< T, SIZE >::Last | ( | ) |
Definition at line 335 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SG_ASSERT.
int SgSList< T, SIZE >::Length | ( | ) | const |
SgSList< T, SIZE > & SgSList< T, SIZE >::operator= | ( | const SgSList< T, SIZE > & | list | ) |
Definition at line 227 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
bool SgSList< T, SIZE >::operator== | ( | const SgSList< T, SIZE > & | list | ) | const |
Definition at line 238 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
Referenced by SgSList< T, SIZE >::operator!=().
const T & SgSList< T, SIZE >::operator[] | ( | int | index | ) | const |
Definition at line 265 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SG_ASSERT.
T & SgSList< T, SIZE >::operator[] | ( | int | index | ) |
Definition at line 257 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SG_ASSERT.
void SgSList< T, SIZE >::PopBack | ( | ) |
void SgSList< T, SIZE >::PushBack | ( | const T & | val | ) |
Definition at line 362 of file SgSList.h.
References SgSList< T, SIZE >::m_array, SgSList< T, SIZE >::m_len, and SG_ASSERT.
Referenced by SgSList< T, SIZE >::Include(), SgSList< T, SIZE >::Intersect(), and SgSList< T, SIZE >::PushBackList().
void SgSList< T, SIZE >::PushBackList | ( | const SgSList< 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 370 of file SgSList.h.
References SgSList< T, SIZE >::PushBack().
void SgSList< T, SIZE >::RemoveFirst | ( | const T & | val | ) |
Remove first occurence of a value.
Preserves order of remaining elements.
Definition at line 377 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
void SgSList< 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 392 of file SgSList.h.
References SgSList< T, SIZE >::m_len, and SG_ASSERT.
bool SgSList< T, SIZE >::SameElements | ( | const SgSList< T, SIZE > & | list | ) | const |
Definition at line 400 of file SgSList.h.
References SgSList< T, SIZE >::Contains(), SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
void SgSList< T, SIZE >::SetTo | ( | const T & | val | ) |
Definition at line 412 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
Referenced by SgSList< T, SIZE >::SgSList().
void SgSList< T, SIZE >::Sort | ( | ) |
Definition at line 419 of file SgSList.h.
References SgSList< T, SIZE >::m_array, and SgSList< T, SIZE >::m_len.
friend class Iterator [friend] |
friend class NonConstIterator [friend] |
Definition at line 149 of file SgSList.h.
Referenced by SgSList< T, SIZE >::Contains(), SgSList< T, SIZE >::Exclude(), SgSList< T, SIZE >::Intersect(), SgSList< T, SIZE >::Last(), SgSList< T, SIZE >::operator=(), SgSList< T, SIZE >::operator==(), SgSList< T, SIZE >::operator[](), SgSList< T, SIZE >::PushBack(), SgSList< T, SIZE >::RemoveFirst(), SgSList< T, SIZE >::SameElements(), SgSList< T, SIZE >::SetTo(), SgSList< T, SIZE >::SgSList(), and SgSList< T, SIZE >::Sort().
Definition at line 147 of file SgSList.h.
Referenced by SgSList< T, SIZE >::Clear(), SgSList< T, SIZE >::Contains(), SgSList< T, SIZE >::Exclude(), SgSList< T, SIZE >::Intersect(), SgSList< T, SIZE >::IsEmpty(), SgSList< T, SIZE >::Last(), SgSList< T, SIZE >::Length(), SgSList< T, SIZE >::operator=(), SgSList< T, SIZE >::operator==(), SgSList< T, SIZE >::operator[](), SgSList< T, SIZE >::PopBack(), SgSList< T, SIZE >::PushBack(), SgSList< T, SIZE >::RemoveFirst(), SgSList< T, SIZE >::Resize(), SgSList< T, SIZE >::SameElements(), SgSList< T, SIZE >::SetTo(), SgSList< T, SIZE >::SgSList(), and SgSList< T, SIZE >::Sort().