Image Component Library (ICL)
|
Simple 2D-Array class that provides shallow copy per default. More...
#include <Array2D.h>
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 Size & | getSize () 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 |
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.
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
typedef const T* icl::utils::Array2D< T >::const_iterator |
const iterator type (just a const T*)
typedef T* icl::utils::Array2D< T >::iterator |
iterator type (just a T*)
icl::utils::Array2D< T >::Array2D | ( | ) | [inline] |
Creates null instance.
icl::utils::Array2D< T >::Array2D | ( | int | w, |
int | h | ||
) | [inline] |
Creates an uninitialized matrix of given size.
icl::utils::Array2D< T >::Array2D | ( | const Size & | s | ) | [inline] |
Creates an uninitialized matrix of given size.
icl::utils::Array2D< T >::Array2D | ( | int | w, |
int | h, | ||
Init | init | ||
) | [inline] |
Creates an initialized matrix with given initializer.
icl::utils::Array2D< T >::Array2D | ( | const Size & | s, |
Init | init | ||
) | [inline] |
Creates an initialized matrix with given initializer.
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.
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.
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)
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)
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.
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.
void icl::utils::Array2D< T >::assign | ( | Iterator | begin, |
Iterator | end | ||
) | [inline] |
Assigns the matrix from given range.
iterator icl::utils::Array2D< T >::begin | ( | ) | [inline] |
upper left matrix element iterator
const_iterator icl::utils::Array2D< T >::begin | ( | ) | const [inline] |
upper left matrix element iterator (const)
T* icl::utils::Array2D< T >::data | ( | ) | [inline] |
returns the data pointer
const T* icl::utils::Array2D< T >::data | ( | ) | const [inline] |
returns the data pointer (const version)
Array2D<T> icl::utils::Array2D< T >::deepCopy | ( | ) | const [inline] |
returns a deep copy of this matrix
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
iterator icl::utils::Array2D< T >::end | ( | ) | [inline] |
upper left matrix element iterator
const_iterator icl::utils::Array2D< T >::end | ( | ) | const [inline] |
upper left matrix element iterator
fills the matrix with given value
int icl::utils::Array2D< T >::getDim | ( | ) | const [inline] |
returns the matrix dimension (width*height)
int icl::utils::Array2D< T >::getHeight | ( | ) | const [inline] |
returns the matrix height
const Size& icl::utils::Array2D< T >::getSize | ( | ) | const [inline] |
returns the matrix size
int icl::utils::Array2D< T >::getWidth | ( | ) | const [inline] |
returns the matrix width
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
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
T& icl::utils::Array2D< T >::operator() | ( | int | x, |
int | y | ||
) | [inline] |
returns element at given x,y position
const T& icl::utils::Array2D< T >::operator() | ( | int | x, |
int | y | ||
) | const [inline] |
returns element at given x,y position (const)
T& icl::utils::Array2D< T >::operator[] | ( | int | idx | ) | [inline] |
returns element at given linear index
const T& icl::utils::Array2D< T >::operator[] | ( | int | idx | ) | const [inline] |
returns element at given linear index (const)
SmartArray<T> icl::utils::Array2D< T >::m_data [private] |
current data
Size icl::utils::Array2D< T >::m_size [private] |
current dimension