Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Private Attributes
icl::utils::Array2D< T > Class Template Reference

Simple 2D-Array class that provides shallow copy per default. More...

#include <Array2D.h>

List of all members.

Public Types

typedef T * iterator
 iterator type (just a T*)
typedef const T * const_iterator
 const iterator type (just a const T*)

Public Member Functions

 Array2D ()
 Creates null instance.
 Array2D (int w, int h)
 Creates an uninitialized matrix of given size.
 Array2D (const Size &s)
 Creates an uninitialized matrix of given size.
template<class Init >
 Array2D (int w, int h, Init init)
 Creates an initialized matrix with given initializer.
template<class Init >
 Array2D (const Size &s, Init init)
 Creates an initialized matrix with given initializer.
 Array2D (int w, int h, T *data, bool deepCopy=false)
 Creates a matrix of size w x h, using given (optionally shared) data.
 Array2D (const Size &s, T *data, bool deepCopy=false)
 Creates a matrix of given Size, using given (optionally shared) data.
 Array2D (int w, int h, const T *data)
 Creates a matrix of size w x h, using given const data (always deep copy)
 Array2D (const Size &s, const T *data)
 Creates a matrix of given Size using given const data (always deep copy)
template<class Iterator >
 Array2D (int w, int h, Iterator begin, Iterator end)
 Creates a matrix of size w x h, initialized with content from given range.
template<class Iterator >
 Array2D (const Size &s, Iterator begin, Iterator end)
 Creates a matrix of size w x h, initialized with content from given range.
template<class Value >
void fill (Value val)
 fills the matrix with given value
template<class Iterator >
void assign (Iterator begin, Iterator end)
 Assigns the matrix from given range.
int getWidth () const
 returns the matrix width
int getHeight () const
 returns the matrix height
int getDim () const
 returns the matrix dimension (width*height)
const SizegetSize () const
 returns the matrix size
T & operator[] (int idx)
 returns element at given linear index
const T & operator[] (int idx) const
 returns element at given linear index (const)
T & operator() (int x, int y)
 returns element at given x,y position
const T & operator() (int x, int y) const
 returns element at given x,y position (const)
iterator begin ()
 upper left matrix element iterator
const_iterator begin () const
 upper left matrix element iterator (const)
iterator end ()
 upper left matrix element iterator
const_iterator end () const
 upper left matrix element iterator
Array2D< T > deepCopy () const
 returns a deep copy of this matrix
void detach ()
 ensures that the contained data is not shared by other instances
T * data ()
 returns the data pointer
const T * data () const
 returns the data pointer (const version)
const T & minElem (Point *pos=0) const
 returns the minumum element of the matrix (operator < must be defined on T)
const T & maxElem (Point *pos=0) const
 returns the maximum element of the matrix (operator < must be defined on T)

Private Attributes

Size m_size
 current dimension
SmartArray< T > m_data
 current data

Detailed Description

template<class T>
class icl::utils::Array2D< T >

Simple 2D-Array class that provides shallow copy per default.

This class replaces the former SimpleMatrix class

In contrast to the DynMatrix<T>-class template, the Array2D is designed for simple 2D data storage. The internal data layout is row-major i.e. the data is stored row-by-row. Array2D instances can be set up to have their own data, that is managed internally using a SmartArray<T> instance, or they can be wrapped around an existing data data pointer. In the latter case, the given data is not copied deeply which implicates that the data must remain valid.

Simplicity

In order to keep the class interface simple, Array2D instances cannot be resized. Simply assign a new instance with new size. Due to the internally used smart pointer, this entails only a very small and constant overhead


Member Typedef Documentation

template<class T>
typedef const T* icl::utils::Array2D< T >::const_iterator

const iterator type (just a const T*)

template<class T>
typedef T* icl::utils::Array2D< T >::iterator

iterator type (just a T*)


Constructor & Destructor Documentation

template<class T>
icl::utils::Array2D< T >::Array2D ( ) [inline]

Creates null instance.

template<class T>
icl::utils::Array2D< T >::Array2D ( int  w,
int  h 
) [inline]

Creates an uninitialized matrix of given size.

template<class T>
icl::utils::Array2D< T >::Array2D ( const Size s) [inline]

Creates an uninitialized matrix of given size.

template<class T>
template<class Init >
icl::utils::Array2D< T >::Array2D ( int  w,
int  h,
Init  init 
) [inline]

Creates an initialized matrix with given initializer.

template<class T>
template<class Init >
icl::utils::Array2D< T >::Array2D ( const Size s,
Init  init 
) [inline]

Creates an initialized matrix with given initializer.

template<class T>
icl::utils::Array2D< T >::Array2D ( int  w,
int  h,
T *  data,
bool  deepCopy = false 
) [inline]

Creates a matrix of size w x h, using given (optionally shared) data.

template<class T>
icl::utils::Array2D< T >::Array2D ( const Size s,
T *  data,
bool  deepCopy = false 
) [inline]

Creates a matrix of given Size, using given (optionally shared) data.

template<class T>
icl::utils::Array2D< T >::Array2D ( int  w,
int  h,
const T *  data 
) [inline]

Creates a matrix of size w x h, using given const data (always deep copy)

template<class T>
icl::utils::Array2D< T >::Array2D ( const Size s,
const T *  data 
) [inline]

Creates a matrix of given Size using given const data (always deep copy)

template<class T>
template<class Iterator >
icl::utils::Array2D< T >::Array2D ( int  w,
int  h,
Iterator  begin,
Iterator  end 
) [inline]

Creates a matrix of size w x h, initialized with content from given range.

template<class T>
template<class Iterator >
icl::utils::Array2D< T >::Array2D ( const Size s,
Iterator  begin,
Iterator  end 
) [inline]

Creates a matrix of size w x h, initialized with content from given range.


Member Function Documentation

template<class T>
template<class Iterator >
void icl::utils::Array2D< T >::assign ( Iterator  begin,
Iterator  end 
) [inline]

Assigns the matrix from given range.

template<class T>
iterator icl::utils::Array2D< T >::begin ( ) [inline]

upper left matrix element iterator

template<class T>
const_iterator icl::utils::Array2D< T >::begin ( ) const [inline]

upper left matrix element iterator (const)

template<class T>
T* icl::utils::Array2D< T >::data ( ) [inline]

returns the data pointer

template<class T>
const T* icl::utils::Array2D< T >::data ( ) const [inline]

returns the data pointer (const version)

template<class T>
Array2D<T> icl::utils::Array2D< T >::deepCopy ( ) const [inline]

returns a deep copy of this matrix

template<class T>
void icl::utils::Array2D< T >::detach ( ) [inline]

ensures that the contained data is not shared by other instances

This method ensure exclusive access to the internal data. I.e. If the data is used by another Array2D instance. This is also true for the shared-data mode, which behaves exactly like the non-shared data mode except that the data-pointer is finally not deleted

template<class T>
iterator icl::utils::Array2D< T >::end ( ) [inline]

upper left matrix element iterator

template<class T>
const_iterator icl::utils::Array2D< T >::end ( ) const [inline]

upper left matrix element iterator

template<class T>
template<class Value >
void icl::utils::Array2D< T >::fill ( Value  val) [inline]

fills the matrix with given value

template<class T>
int icl::utils::Array2D< T >::getDim ( ) const [inline]

returns the matrix dimension (width*height)

template<class T>
int icl::utils::Array2D< T >::getHeight ( ) const [inline]

returns the matrix height

template<class T>
const Size& icl::utils::Array2D< T >::getSize ( ) const [inline]

returns the matrix size

template<class T>
int icl::utils::Array2D< T >::getWidth ( ) const [inline]

returns the matrix width

template<class T>
const T& icl::utils::Array2D< T >::maxElem ( Point pos = 0) const [inline]

returns the maximum element of the matrix (operator < must be defined on T)

If the optional argument pos is given and it is not 0, *pos is set to the maximum elements x,y position in the matrix

template<class T>
const T& icl::utils::Array2D< T >::minElem ( Point pos = 0) const [inline]

returns the minumum element of the matrix (operator < must be defined on T)

If the optional argument pos is given and it is not 0, *pos is set to the minimum elements x,y position in the matrix

template<class T>
T& icl::utils::Array2D< T >::operator() ( int  x,
int  y 
) [inline]

returns element at given x,y position

template<class T>
const T& icl::utils::Array2D< T >::operator() ( int  x,
int  y 
) const [inline]

returns element at given x,y position (const)

template<class T>
T& icl::utils::Array2D< T >::operator[] ( int  idx) [inline]

returns element at given linear index

template<class T>
const T& icl::utils::Array2D< T >::operator[] ( int  idx) const [inline]

returns element at given linear index (const)


Member Data Documentation

template<class T>
SmartArray<T> icl::utils::Array2D< T >::m_data [private]

current data

template<class T>
Size icl::utils::Array2D< T >::m_size [private]

current dimension


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines