structures::matrix< contents > Class Template Reference

Represents a two-dimensional array of objects. More...

#include <matrix.h>

Inheritance diagram for structures::matrix< contents >:
Inheritance graph
[legend]
Collaboration diagram for structures::matrix< contents >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 matrix (int rows=0, int cols=0, contents *data=NIL)
 the "data" array must have at least "rows" * "cols" contents in it.
 matrix (const matrix &to_copy)
 ~matrix ()
int rows () const
int columns () const
matrixoperator= (const matrix &to_copy)
contents & get (int row, int column)
const contents & get (int row, int column) const
 retrieves the contents from the specified "row" and "column".
bool put (int row, int column, const contents &to_put)
 stores "to_put" into the matrix at "row" and "column".
contents * operator[] (int row)
 dangerous: indexes by "row" into the underlying contents.
const contents * operator[] (int row) const
 dangerous: constant peek into data for "row" in underlying contents.
matrix submatrix (int row, int column, int rows, int columns) const
 returns a submatrix of this one starting at "row" and "column".
void submatrix (matrix &sub, int row, int column, int rows, int cols) const
 like submatrix() above, but stores into the "sub" parameter.
matrix transpose () const
 provides the transposed form of this matrix.
void transpose (matrix &resultant) const
 stores the transpose of this matrix in "resultant".
basis::array< contents > get_row (int row)
 return the vector at the "row", or an empty array if "row" is invalid.
basis::array< contents > get_column (int column)
 return the vector at the "column", or an empty array if it's invalid.
bool insert_row (int before_row)
 inserts a row before the "before_" parameter.
bool insert_column (int before_column)
 inserts a column before the "before_" parameter.
void reset (int rows=0, int columns=0)
 empties the matrix and changes its size.
void redimension (int new_rows, int new_columns)
 changes the size to contain "new_rows" by "new_columns" elements.
bool zap_row (int row_to_zap)
bool zap_column (int column_to_zap)
 removes a row or column from the matrix.

Detailed Description

template<class contents>
class structures::matrix< contents >

Represents a two-dimensional array of objects.

The indices range from zero to (maximum_value - 1) for rows and columns.

Definition at line 31 of file matrix.h.


Constructor & Destructor Documentation

template<class contents>
structures::matrix< contents >::matrix ( int  rows = 0,
int  cols = 0,
contents *  data = NIL 
) [inline]

the "data" array must have at least "rows" * "cols" contents in it.

Definition at line 149 of file matrix.h.

template<class contents>
structures::matrix< contents >::matrix ( const matrix< contents > &  to_copy  )  [inline]

Definition at line 153 of file matrix.h.

template<class contents>
structures::matrix< contents >::~matrix (  )  [inline]

Definition at line 38 of file matrix.h.


Member Function Documentation

template<class contents>
int structures::matrix< contents >::columns (  )  const [inline]
template<class contents >
const contents & structures::matrix< contents >::get ( int  row,
int  column 
) const [inline]

retrieves the contents from the specified "row" and "column".

Definition at line 176 of file matrix.h.

References structures::matrix< contents >::get().

template<class contents >
contents & structures::matrix< contents >::get ( int  row,
int  column 
) [inline]
template<class contents >
basis::array< contents > structures::matrix< contents >::get_column ( int  column  )  [inline]

return the vector at the "column", or an empty array if it's invalid.

Definition at line 277 of file matrix.h.

References structures::matrix< contents >::columns(), basis::array< contents >::reset(), and structures::matrix< contents >::rows().

template<class contents >
basis::array< contents > structures::matrix< contents >::get_row ( int  row  )  [inline]

return the vector at the "row", or an empty array if "row" is invalid.

Definition at line 266 of file matrix.h.

References structures::matrix< contents >::columns(), basis::array< contents >::reset(), and structures::matrix< contents >::rows().

template<class contents >
bool structures::matrix< contents >::insert_column ( int  before_column  )  [inline]

inserts a column before the "before_" parameter.

Definition at line 333 of file matrix.h.

References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, structures::matrix< contents >::put(), and structures::matrix< contents >::rows().

template<class contents >
bool structures::matrix< contents >::insert_row ( int  before_row  )  [inline]

inserts a row before the "before_" parameter.

all existing data is preserved in the matrix, although it may get moved over depending on where it's located with respect to "before_row".

Definition at line 319 of file matrix.h.

References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, basis::array< contents >::insert(), structures::matrix< contents >::put(), and structures::matrix< contents >::rows().

template<class contents >
matrix< contents > & structures::matrix< contents >::operator= ( const matrix< contents > &  to_copy  )  [inline]

Definition at line 158 of file matrix.h.

template<class contents >
const contents * structures::matrix< contents >::operator[] ( int  row  )  const [inline]

dangerous: constant peek into data for "row" in underlying contents.

Reimplemented from basis::array< contents >.

Definition at line 172 of file matrix.h.

References structures::matrix< contents >::operator[]().

template<class contents >
contents * structures::matrix< contents >::operator[] ( int  row  )  [inline]

dangerous: indexes by "row" into the underlying contents.

the result can be used as a pointer to the whole row of data, or it can be indexed into by column to find a row/column position. this is dangerous if one is not careful about ensuring that the column used is within bounds. if the "row" parameter is out of bounds, then NIL is returned.

Reimplemented from basis::array< contents >.

Definition at line 168 of file matrix.h.

Referenced by structures::matrix< contents >::get(), structures::matrix< contents >::operator[](), and structures::matrix< contents >::put().

template<class contents>
bool structures::matrix< contents >::put ( int  row,
int  column,
const contents &  to_put 
) [inline]
template<class contents >
void structures::matrix< contents >::redimension ( int  new_rows,
int  new_columns 
) [inline]

changes the size to contain "new_rows" by "new_columns" elements.

data that was held previously stays in the array as long as its row and column indices are still valid.

Definition at line 207 of file matrix.h.

References structures::matrix< contents >::columns(), basis::minimum(), and structures::matrix< contents >::rows().

template<class contents >
void structures::matrix< contents >::reset ( int  rows = 0,
int  columns = 0 
) [inline]

empties the matrix and changes its size.

Definition at line 188 of file matrix.h.

References basis::array< contents >::insert().

Referenced by structures::matrix< contents >::submatrix(), and structures::matrix< contents >::transpose().

template<class contents>
int structures::matrix< contents >::rows (  )  const [inline]
template<class contents >
void structures::matrix< contents >::submatrix ( matrix< contents > &  sub,
int  row,
int  column,
int  rows,
int  cols 
) const [inline]

like submatrix() above, but stores into the "sub" parameter.

Definition at line 236 of file matrix.h.

References structures::matrix< contents >::columns(), structures::matrix< contents >::reset(), and structures::matrix< contents >::rows().

template<class contents >
matrix< contents > structures::matrix< contents >::submatrix ( int  row,
int  column,
int  rows,
int  columns 
) const [inline]

returns a submatrix of this one starting at "row" and "column".

The returned matrix should contain "rows" rows and "columns" columns. if the size or position are out of bounds, an empty matrix is returned.

Definition at line 227 of file matrix.h.

template<class contents >
void structures::matrix< contents >::transpose ( matrix< contents > &  resultant  )  const [inline]

stores the transpose of this matrix in "resultant".

Definition at line 257 of file matrix.h.

References structures::matrix< contents >::columns(), structures::matrix< contents >::reset(), and structures::matrix< contents >::rows().

template<class contents >
matrix< contents > structures::matrix< contents >::transpose (  )  const [inline]

provides the transposed form of this matrix.

Definition at line 249 of file matrix.h.

template<class contents >
bool structures::matrix< contents >::zap_column ( int  column_to_zap  )  [inline]

removes a row or column from the matrix.

the matrix becomes one row or column less than before and all data from the deleted vector is lost.

Definition at line 304 of file matrix.h.

References bounds_halt, structures::matrix< contents >::columns(), FUNCDEF, structures::matrix< contents >::rows(), and basis::array< contents >::zap().

template<class contents >
bool structures::matrix< contents >::zap_row ( int  row_to_zap  )  [inline]

The documentation for this class was generated from the following file:
Generated on Sat Jan 28 04:25:56 2012 for hoople2 project by  doxygen 1.6.3