base::SmallArray< FIXED_SIZE, T > Class Template Reference

Pretends to have a variable-size (but underlying array is fixed-size). More...

#include <base_types_array.hh>

List of all members.

Public Types

typedef T Type

Public Member Functions

 SmallArray (const uint varSize=0)
 SmallArray (const SmallArray< FIXED_SIZE, T > &src)
 Copy constructor.
T & operator[] (uint i)
const T & operator[] (uint i) const
SmallArray
< FIXED_SIZE, T > & 
operator= (const SmallArray< FIXED_SIZE, T > &src)
 Amazing that a C++ compiler will accept how this type is written.
bool operator== (const SmallArray< FIXED_SIZE, T > &src) const
bool operator!= (const SmallArray< FIXED_SIZE, T > &src) const
bool operator< (const SmallArray< FIXED_SIZE, T > &src) const
T * PTR (void) const
const T * CONST_PTR (void) const
uint size (void) const
 Limited STL compatibility.
void resize (const uint varSize)
void clear (void)
bool empty (void) const
void push_back (T item)

Private Attributes

uint mVarSize
mArray [FIXED_SIZE]


Detailed Description

template<uint FIXED_SIZE, typename T = int>
class base::SmallArray< FIXED_SIZE, T >

Pretends to have a variable-size (but underlying array is fixed-size).

Limited-use (for speed/memory optimization).

Like TinyArray, SmallArray's underlying array really is fixed-size, but SmallArray pretends to have variable-size which allows push_back(), size(), resize(). SmallArray's advantage over STL vector is reduced memory consumption and allocation.

NOTE: resize() will fail if new size is beyond fixed-size.

Usage: ------ This pre-allocates space for 256 elements (FIXED-SIZE). But its VARIABLE-SIZE is zero: empty() and size() indicate zero elements!

SmallArray<256,int> array; if ( array.empty() ) Func(); // yes, Func() will be called

Idiom: SmallArray<1000,int> array( 1000 ); // fixed-size = variable-size


Member Typedef Documentation

template<uint FIXED_SIZE, typename T = int>
typedef T base::SmallArray< FIXED_SIZE, T >::Type


Constructor & Destructor Documentation

template<uint FIXED_SIZE, typename T = int>
base::SmallArray< FIXED_SIZE, T >::SmallArray ( const uint  varSize = 0  )  [inline]

template<uint FIXED_SIZE, typename T = int>
base::SmallArray< FIXED_SIZE, T >::SmallArray ( const SmallArray< FIXED_SIZE, T > &  src  )  [inline]

Copy constructor.


Member Function Documentation

template<uint FIXED_SIZE, typename T = int>
T& base::SmallArray< FIXED_SIZE, T >::operator[] ( uint  i  )  [inline]

Catching access to an uninitialized element would be ideal but there's no way to tell if the element is being read or written.

template<uint FIXED_SIZE, typename T = int>
const T& base::SmallArray< FIXED_SIZE, T >::operator[] ( uint  i  )  const [inline]

template<uint FIXED_SIZE, typename T = int>
SmallArray<FIXED_SIZE,T>& base::SmallArray< FIXED_SIZE, T >::operator= ( const SmallArray< FIXED_SIZE, T > &  src  )  [inline]

Amazing that a C++ compiler will accept how this type is written.

template<uint FIXED_SIZE, typename T = int>
bool base::SmallArray< FIXED_SIZE, T >::operator== ( const SmallArray< FIXED_SIZE, T > &  src  )  const [inline]

template<uint FIXED_SIZE, typename T = int>
bool base::SmallArray< FIXED_SIZE, T >::operator!= ( const SmallArray< FIXED_SIZE, T > &  src  )  const [inline]

template<uint FIXED_SIZE, typename T = int>
bool base::SmallArray< FIXED_SIZE, T >::operator< ( const SmallArray< FIXED_SIZE, T > &  src  )  const [inline]

template<uint FIXED_SIZE, typename T = int>
T* base::SmallArray< FIXED_SIZE, T >::PTR ( void   )  const [inline]

template<uint FIXED_SIZE, typename T = int>
const T* base::SmallArray< FIXED_SIZE, T >::CONST_PTR ( void   )  const [inline]

template<uint FIXED_SIZE, typename T = int>
uint base::SmallArray< FIXED_SIZE, T >::size ( void   )  const [inline]

Limited STL compatibility.

template<uint FIXED_SIZE, typename T = int>
void base::SmallArray< FIXED_SIZE, T >::resize ( const uint  varSize  )  [inline]

template<uint FIXED_SIZE, typename T = int>
void base::SmallArray< FIXED_SIZE, T >::clear ( void   )  [inline]

template<uint FIXED_SIZE, typename T = int>
bool base::SmallArray< FIXED_SIZE, T >::empty ( void   )  const [inline]

template<uint FIXED_SIZE, typename T = int>
void base::SmallArray< FIXED_SIZE, T >::push_back ( item  )  [inline]


Member Data Documentation

template<uint FIXED_SIZE, typename T = int>
uint base::SmallArray< FIXED_SIZE, T >::mVarSize [private]

template<uint FIXED_SIZE, typename T = int>
T base::SmallArray< FIXED_SIZE, T >::mArray[FIXED_SIZE] [private]


The documentation for this class was generated from the following file: Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:20 2007