base::Array2D< T, BASE > Class Template Reference

2D array that clamps indexs. More...

#include <_src_base_array_2d.hh>

List of all members.

Public Member Functions

 Array2D (void)
 Array2D (const int sx, const int sy)
 (sx,sy) defines 2D size.
 ~Array2D ()
void resize (const int sx, const int sy)
void clear (void)
uint size (void) const
uint width (void) const
uint height (void) const
bool empty (void) const
uint Index1D (int x, int y) const
void Set (const int x, const int y, const T &val)
T & Get (const int x, const int y)
const T & Get (const int x, const int y) const
 R/O access to element by its 2D coordinates.
T & operator[] (const uint index1D)
 R/W access to element by its 1D index.
const T & operator[] (const uint index1D) const
 R/O access to element by its 1D index.

Private Attributes

int mSx
 size of X dimension
int mSy
 size of Y dimension
int mSxM1
 mSx - 1
int mSyM1
 mSx - 1
vector< T > mVec
 actual array


Detailed Description

template<typename T, typename BASE = Void>
class base::Array2D< T, BASE >

2D array that clamps indexs.

Indexs are signed, rather than unsigned, to clamp negative indexs at 0.

Array2D is allowed to be initially empty which is defined as sx=sy=0. Methods that access elements become invalid when an array is empty.


Constructor & Destructor Documentation

template<typename T, typename BASE = Void>
base::Array2D< T, BASE >::Array2D ( void   )  [inline]

template<typename T, typename BASE = Void>
base::Array2D< T, BASE >::Array2D ( const int  sx,
const int  sy 
) [inline]

(sx,sy) defines 2D size.

template<typename T, typename BASE = Void>
base::Array2D< T, BASE >::~Array2D (  )  [inline]


Member Function Documentation

template<typename T, typename BASE = Void>
void base::Array2D< T, BASE >::resize ( const int  sx,
const int  sy 
) [inline]

template<typename T, typename BASE = Void>
void base::Array2D< T, BASE >::clear ( void   )  [inline]

template<typename T, typename BASE = Void>
uint base::Array2D< T, BASE >::size ( void   )  const [inline]

template<typename T, typename BASE = Void>
uint base::Array2D< T, BASE >::width ( void   )  const [inline]

template<typename T, typename BASE = Void>
uint base::Array2D< T, BASE >::height ( void   )  const [inline]

template<typename T, typename BASE = Void>
bool base::Array2D< T, BASE >::empty ( void   )  const [inline]

template<typename T, typename BASE = Void>
uint base::Array2D< T, BASE >::Index1D ( int  x,
int  y 
) const [inline]

Returns:
Convert 2D index to 1D index.

template<typename T, typename BASE = Void>
void base::Array2D< T, BASE >::Set ( const int  x,
const int  y,
const T &  val 
) [inline]

Write to element by its 2D coordinates. The order of args of Set() is similar to: mArray[x][y] = val; mArray.Set( x, y, val );

template<typename T, typename BASE = Void>
T& base::Array2D< T, BASE >::Get ( const int  x,
const int  y 
) [inline]

R/W access to element by its 2D coordinates. Can be used to write to element (Set() is more sensible).

template<typename T, typename BASE = Void>
const T& base::Array2D< T, BASE >::Get ( const int  x,
const int  y 
) const [inline]

R/O access to element by its 2D coordinates.

template<typename T, typename BASE = Void>
T& base::Array2D< T, BASE >::operator[] ( const uint  index1D  )  [inline]

R/W access to element by its 1D index.

template<typename T, typename BASE = Void>
const T& base::Array2D< T, BASE >::operator[] ( const uint  index1D  )  const [inline]

R/O access to element by its 1D index.


Member Data Documentation

template<typename T, typename BASE = Void>
int base::Array2D< T, BASE >::mSx [private]

size of X dimension

template<typename T, typename BASE = Void>
int base::Array2D< T, BASE >::mSy [private]

size of Y dimension

template<typename T, typename BASE = Void>
int base::Array2D< T, BASE >::mSxM1 [private]

mSx - 1

template<typename T, typename BASE = Void>
int base::Array2D< T, BASE >::mSyM1 [private]

mSx - 1

template<typename T, typename BASE = Void>
vector<T> base::Array2D< T, BASE >::mVec [private]

actual array


The documentation for this class was generated from the following file:
Palomino Flight Simulator documents generated by doxygen 1.5.6 on Tue Sep 28 11:37:49 2010