Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Classes | Public Member Functions | Private Attributes | Friends

SgArrayList< T, SIZE > Class Template Reference

Static list not using dynamic memory allocation. More...

#include <SgArrayList.h>

List of all members.

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)
SgArrayListoperator= (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
m_array [SIZE]

Friends

class Iterator
class NonConstIterator

Detailed Description

template<typename T, int SIZE>
class SgArrayList< T, SIZE >

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.


Constructor & Destructor Documentation

template<typename T , int SIZE>
SgArrayList< T, SIZE >::SgArrayList (  ) 

Definition at line 199 of file SgArrayList.h.

template<typename T, int SIZE>
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().

template<typename T, int SIZE>
SgArrayList< T, SIZE >::SgArrayList ( const SgArrayList< T, SIZE > &  list  ) 

Definition at line 213 of file SgArrayList.h.


Member Function Documentation

template<typename T , int SIZE>
void SgArrayList< T, SIZE >::Clear (  ) 

Definition at line 265 of file SgArrayList.h.

References SgArrayList< T, SIZE >::m_len.

template<typename T, int SIZE>
bool SgArrayList< T, SIZE >::Contains ( const T &  val  )  const
template<typename T, int SIZE>
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.

Returns:
false, if element was not found

Definition at line 282 of file SgArrayList.h.

References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.

template<typename T, int SIZE>
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().

template<typename T, int SIZE>
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.

template<typename T , int SIZE>
bool SgArrayList< T, SIZE >::IsEmpty (  )  const

Definition at line 321 of file SgArrayList.h.

References SgArrayList< T, SIZE >::m_len.

template<typename T , int SIZE>
T & SgArrayList< T, SIZE >::Last (  ) 
template<typename T , int SIZE>
const T & SgArrayList< T, SIZE >::Last (  )  const
template<typename T , int SIZE>
int SgArrayList< T, SIZE >::Length (  )  const

Definition at line 341 of file SgArrayList.h.

References SgArrayList< T, SIZE >::m_len.

template<typename T , int SIZE>
bool SgArrayList< T, SIZE >::operator!= ( const SgArrayList< T, SIZE > &  list  )  const

Definition at line 243 of file SgArrayList.h.

References SgArrayList< T, SIZE >::operator==().

template<typename T , int SIZE>
SgArrayList< T, SIZE > & SgArrayList< T, SIZE >::operator= ( const SgArrayList< T, SIZE > &  list  ) 
template<typename T , int SIZE>
bool SgArrayList< T, SIZE >::operator== ( const SgArrayList< T, SIZE > &  list  )  const
template<typename T , int SIZE>
T & SgArrayList< T, SIZE >::operator[] ( int  index  ) 
template<typename T , int SIZE>
const T & SgArrayList< T, SIZE >::operator[] ( int  index  )  const
template<typename T , int SIZE>
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.

template<typename T, int SIZE>
void SgArrayList< T, SIZE >::PushBack ( const T &  val  ) 
template<typename T, int SIZE>
template<int SIZE2>
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().

template<typename T, int SIZE>
void SgArrayList< T, SIZE >::RemoveFirst ( const T &  val  ) 

Remove first occurence of a value.

Preserves order of remaining elements.

See also:
Exclude

Definition at line 369 of file SgArrayList.h.

References SgArrayList< T, SIZE >::m_array, and SgArrayList< T, SIZE >::m_len.

template<typename T , int SIZE>
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.

template<typename T , int SIZE>
bool SgArrayList< T, SIZE >::SameElements ( const SgArrayList< T, SIZE > &  list  )  const
template<typename T, int SIZE>
void SgArrayList< T, SIZE >::SetTo ( const T &  val  ) 
template<typename T , int SIZE>
void SgArrayList< T, SIZE >::Sort (  ) 

Friends And Related Function Documentation

template<typename T, int SIZE>
friend class Iterator [friend]

Definition at line 135 of file SgArrayList.h.

template<typename T, int SIZE>
friend class NonConstIterator [friend]

Definition at line 136 of file SgArrayList.h.


Member Data Documentation

template<typename T, int SIZE>
T SgArrayList< T, SIZE >::m_array[SIZE] [private]
template<typename T, int SIZE>
int SgArrayList< T, SIZE >::m_len [private]

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


Sun Mar 13 2011 Doxygen 1.7.1