Basic2DArray Class Template Reference

A 2D array data type that manages the allocation and deallocation of memory. More...

#include <Basic2DArray.h>

Inheritance diagram for Basic2DArray::

Simple2DArray Num2DArray List of all members.

Public Methods

 Basic2DArray ()
 Null constructor.

 Basic2DArray (const BasicArray< T > &array, const size_type nrows=1, const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the 2D array using a given array. More...

 Basic2DArray (const size_type nrows, const size_type ncols, T *d=((T *) 0), const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the 2D array using a given array. More...

 Basic2DArray (const size_type nrows, const size_type ncols, const BasicArray< T > &array, const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the 2D array using a given array. More...

 Basic2DArray (const Basic2DArray &array)
 Copy constructor.

virtual ~Basic2DArray ()
 Destructor.

int resize (const size_type nrows, const size_type ncols)
 Resize the 2D array.

size_type nrows () const
 Returns the number of rows in the 2D array.

size_type ncols () const
 Returns the number of columns in the 2D array.

 operator T ** () const
 Coersion operator that returns the internal array of pointers.

T ** data () const
 Returns the internal array of pointers.

int nrefs () const
 Returns the number of references to the internal array.

T * operator[] (const int i)
 Returns the i-th row of the 2D array.

T * operator[] (const int i) const
 Returns the i-th row of the 2D array.

T * operator[] (const size_type i)
 Returns the i-th row of the 2D array.

T * operator[] (const size_type i) const
 Returns the i-th row of the 2D array.

T & operator() (const size_type row, const size_type col)
 Returns the element from the row-th row and col-th column.

const T & operator() (const size_type row, const size_type col) const
 Returns the element from the row-th row and col-th column.

Basic2DArray< T > & operator= (const Basic2DArray< T > &array)
 Copies the array object by constructing a new Basic2DArray.

Basic2DArray< T > & operator &= (const Basic2DArray< T > &array)
 Copies the pointer from the array object.

Basic2DArray< T > & operator<< (const Basic2DArray< T > &array)
 Copies the 2D array without memory allocation.

Basic2DArray< T > & operator= (const T &val)
 Set all elements of the array to val.

Basic2DArray< T > & operator= (const BasicArray< T > &val)
 Set all rows of the 2D array to val.

Basic2DArray< T > & set_data (const size_type len, T *data, const EnumDataOwned o=DataNotOwned)
 Method to explicitly set the internal data array. More...

Basic2DArray< T > & set_data (const BasicArray< T > &array, const EnumDataOwned o=DataNotOwned)
 Method to explicitly set the internal data array using a BasicArray object.


Protected Methods

void construct (const size_type nrows, const size_type ncols, T *d, const EnumDataOwned o=DataNotOwned)
 Constructor method that provides the array of data elements.

void construct (const size_type nrows, const size_type ncols, T **d, const EnumDataOwned o=DataNotOwned)
 Constructor method that provides the complete 2D array.

void free ()
 Method used to free up the 2D array.


Protected Attributes

Basic2DArrayRep< T > * a
 Pointer to the 2D array representation.


Detailed Description

template<class T>
class Basic2DArray< T >

A 2D array data type that manages the allocation and deallocation of memory.

Note that 2DArrays are different from Arrays of Arrays, though they are quite similar. This class is similar to a dense matrix class, and it should probably be replaced with a real dense matrix facility.


Constructor & Destructor Documentation

template<class T>
Basic2DArray< T >::Basic2DArray const BasicArray< T > &    array,
const size_type    nrows = 1,
const EnumDataOwned    own = DataNotOwned
[inline]
 

Constructor that initializes the 2D array using a given array.

The 2D array only constructs the array of pointers, which point into the data owned by the array object.

template<class T>
Basic2DArray< T >::Basic2DArray const size_type    nrows,
const size_type    ncols,
T *    d = ((T*)0),
const EnumDataOwned    own = DataNotOwned
[inline]
 

Constructor that initializes the 2D array using a given array.

The 2D array only constructs the array of pointers, which point into the data owned by the d object.

template<class T>
Basic2DArray< T >::Basic2DArray const size_type    nrows,
const size_type    ncols,
const BasicArray< T > &    array,
const EnumDataOwned    own = DataNotOwned
[inline]
 

Constructor that initializes the 2D array using a given array.

The 2D array only constructs the array of pointers, which point into the data owned by the array object.


Member Function Documentation

template<class T>
Basic2DArray< T > & Basic2DArray< T >::set_data const size_type    len,
T *    data,
const EnumDataOwned    o = DataNotOwned
 

Method to explicitly set the internal data array.

The current array is resized to length len, and pointers in the array are setup to point into the data array.


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