feisty meow concerns codebase
2.140
|
Represents a two-dimensional array of objects. More...
#include <matrix.h>
Public Member Functions | |
matrix (int rows=0, int cols=0, contents *data=NULL_POINTER) | |
the "data" array must have at least "rows" * "cols" contents in it. More... | |
matrix (const matrix &to_copy) | |
~matrix () | |
int | rows () const |
int | columns () const |
matrix & | operator= (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". More... | |
bool | put (int row, int column, const contents &to_put) |
stores "to_put" into the matrix at "row" and "column". More... | |
contents * | operator[] (int row) |
dangerous: indexes by "row" into the underlying contents. More... | |
const contents * | operator[] (int row) const |
dangerous: constant peek into data for "row" in underlying contents. More... | |
matrix | submatrix (int row, int column, int rows, int columns) const |
returns a submatrix of this one starting at "row" and "column". More... | |
void | submatrix (matrix &sub, int row, int column, int rows, int cols) const |
like submatrix() above, but stores into the "sub" parameter. More... | |
matrix | transpose () const |
provides the transposed form of this matrix. More... | |
void | transpose (matrix &resultant) const |
stores the transpose of this matrix in "resultant". More... | |
basis::array< contents > | get_row (int row) |
return the vector at the "row", or an empty array if "row" is invalid. More... | |
basis::array< contents > | get_column (int column) |
return the vector at the "column", or an empty array if it's invalid. More... | |
bool | insert_row (int before_row) |
inserts a row before the "before_" parameter. More... | |
bool | insert_column (int before_column) |
inserts a column before the "before_" parameter. More... | |
void | reset (int rows=0, int columns=0) |
empties the matrix and changes its size. More... | |
void | redimension (int new_rows, int new_columns) |
changes the size to contain "new_rows" by "new_columns" elements. More... | |
bool | zap_row (int row_to_zap) |
bool | zap_column (int column_to_zap) |
removes a row or column from the matrix. More... | |
Additional Inherited Members | |
Protected Types inherited from basis::array< contents > | |
enum | specialc_flags { NO_SPECIAL_MODES = 0x0 , SIMPLE_COPY = 0x1 , EXPONENTIAL_GROWTH = 0x2 , EXPONE = EXPONENTIAL_GROWTH , FLUSH_INVISIBLE = 0x4 } |
the flags specify how the array treats its contents and its length. More... | |
enum | how_to_copy { NEW_AT_END , NEW_AT_BEGINNING , DONT_COPY } |
enum | shift_directions { TO_LEFT , TO_RIGHT } |
Protected Member Functions inherited from basis::array< contents > | |
DEFINE_CLASS_NAME ("array") | |
array (int number=0, const contents *init=NULL_POINTER, int flags=EXPONENTIAL_GROWTH|FLUSH_INVISIBLE) | |
Constructs an array with room for "number" objects. More... | |
array (const array< contents > ©_from) | |
copies the contents & sizing information from "copy_from". More... | |
virtual | ~array () |
destroys the memory allocated for the objects. More... | |
void | reset (int number=0, const contents *initial_contents=NULL_POINTER) |
Resizes this array and sets the contents from an array of contents. More... | |
array & | operator= (const array< contents > ©_from) |
Copies the array in "copy_from" into this. More... | |
int | length () const |
Returns the current reported length of the allocated C array. More... | |
int | last () const |
Returns the last valid element in the array. More... | |
int | flags () const |
Provides the raw flags value, without interpreting what it means. More... | |
bool | exponential () const |
Returns true if this allocator will grow exponentially on resize. More... | |
bool | simple () const |
Reports whether the templated object is a simple type or not. More... | |
const contents & | get (int index) const |
Accesses individual objects stored in "this" at the "index" position. More... | |
contents & | use (int index) |
A non-constant version of get(); the returned object can be modified. More... | |
const contents & | operator[] (int index) const |
Synonym for get that provides the expected array indexing syntax. More... | |
contents & | operator[] (int index) |
Synonym for use that provides the expected array indexing syntax. More... | |
outcome | put (int index, const contents &to_put) |
Stores an object at the index "index" in the array. More... | |
array | concatenation (const array &to_concatenate) const |
Returns the concatenation of "this" and the array "to_concatenate". More... | |
array | concatenation (const contents &to_concatenate) const |
Returns the concatenation of "this" and the object "to_concatenate". More... | |
array & | concatenate (const array &to_concatenate) |
Appends the array "to_concatenate" onto "this" and returns "this". More... | |
array & | concatenate (const contents &to_concatenate) |
Appends the object "to_concatenate" onto "this" and returns "this". More... | |
array & | concatenate (const contents *to_concatenate, int length) |
Concatenates a C-array "to_concatenate" onto "this" and returns "this". More... | |
array | operator+ (const array &to_cat) const |
Synonym for concatenation. More... | |
array | operator+ (const contents &to_concatenate) const |
Synonym for concatenation. More... | |
array & | operator+= (const array &to_concatenate) |
Synonym for concatenate that modifies "this". More... | |
array & | operator+= (const contents &to_concatenate) |
Synonym for concatenate that modifies "this". More... | |
const contents * | observe () const |
Returns a pointer to the underlying C array of data. More... | |
contents * | access () |
A non-constant access of the underlying C-array. BE REALLY CAREFUL. More... | |
void | swap_contents (array< contents > &other) |
Exchanges the contents of "this" and "other". More... | |
void | snarf (array &new_contents) |
Drops "this" array's contents into the dustbin and uses "new_contents". More... | |
array | subarray (int start, int end) const |
Returns the array segment between the indices "start" and "end". More... | |
outcome | insert (int index, int new_indices) |
Adds "new_indices" new positions for objects into the array at "index". More... | |
outcome | overwrite (int index, const array &write_with, int count=-1) |
Stores the array "write_with" into the current array at the "index". More... | |
outcome | stuff (int length, contents *to_stuff) const |
Copies at most "length" elements from this into the array "to_stuff". More... | |
outcome | resize (int new_size, how_to_copy way=NEW_AT_END) |
Changes the size of the C array to "new_size". More... | |
outcome | zap (int start, int end) |
Deletes from "this" the objects inclusively between "start" and "end". More... | |
outcome | shrink () |
Cuts loose any allocated space that is beyond the real length. More... | |
outcome | retrain (int new_size, const contents *to_copy) |
Resizes the C array and stuffs it with the contents in "to_copy". More... | |
void | shift_data (shift_directions where) |
The valid portion of the array is moved to the left or right. More... | |
int | internal_real_length () const |
Gritty Internal: the real allocated length. More... | |
int | internal_offset () const |
Gritty Internal: the offset from real start to stored data. More... | |
const contents * | internal_block_start () const |
Gritty Internal: constant peek at the real allocated pointer. More... | |
contents * | internal_block_start () |
Gritty Internal: the real allocated pointer made accessible. More... | |
contents *const * | internal_offset_mem () const |
Gritty Internal: the start of the actual stored data. More... | |
Represents a two-dimensional array of objects.
The indices range from zero to (maximum_value - 1) for rows and columns.
structures::matrix< contents >::matrix | ( | int | rows = 0 , |
int | cols = 0 , |
||
contents * | data = NULL_POINTER |
||
) |
structures::matrix< contents >::matrix | ( | const matrix< contents > & | to_copy | ) |
|
inline |
|
inline |
contents & structures::matrix< contents >::get | ( | int | row, |
int | column | ||
) |
Definition at line 180 of file matrix.h.
References basis::array< contents >::operator[]().
const contents & structures::matrix< contents >::get | ( | int | row, |
int | column | ||
) | const |
retrieves the contents from the specified "row" and "column".
Definition at line 176 of file matrix.h.
References basis::array< contents >::get().
basis::array< contents > structures::matrix< contents >::get_column | ( | int | column | ) |
return the vector at the "column", or an empty array if it's invalid.
Definition at line 277 of file matrix.h.
References basis::array< contents >::reset().
basis::array< contents > structures::matrix< contents >::get_row | ( | int | row | ) |
return the vector at the "row", or an empty array if "row" is invalid.
Definition at line 266 of file matrix.h.
References basis::array< contents >::reset().
bool structures::matrix< contents >::insert_column | ( | int | before_column | ) |
inserts a column before the "before_" parameter.
Definition at line 333 of file matrix.h.
References bounds_halt, and FUNCDEF.
bool structures::matrix< contents >::insert_row | ( | int | before_row | ) |
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, FUNCDEF, and basis::array< contents >::insert().
matrix< contents > & structures::matrix< contents >::operator= | ( | const matrix< contents > & | to_copy | ) |
Definition at line 158 of file matrix.h.
References basis::array< contents >::operator=().
contents * structures::matrix< contents >::operator[] | ( | int | row | ) |
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 NULL_POINTER is returned.
Definition at line 168 of file matrix.h.
References basis::array< contents >::operator[]().
const contents * structures::matrix< contents >::operator[] | ( | int | row | ) | const |
dangerous: constant peek into data for "row" in underlying contents.
Definition at line 172 of file matrix.h.
References basis::array< contents >::operator[]().
bool structures::matrix< contents >::put | ( | int | row, |
int | column, | ||
const contents & | to_put | ||
) |
void structures::matrix< contents >::redimension | ( | int | new_rows, |
int | new_columns | ||
) |
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 basis::minimum().
void structures::matrix< contents >::reset | ( | int | rows = 0 , |
int | columns = 0 |
||
) |
empties the matrix and changes its size.
Definition at line 188 of file matrix.h.
References basis::array< contents >::reset().
Referenced by structures::matrix< contents >::submatrix(), and structures::matrix< contents >::transpose().
|
inline |
matrix< contents > structures::matrix< contents >::submatrix | ( | int | row, |
int | column, | ||
int | rows, | ||
int | columns | ||
) | const |
void structures::matrix< contents >::submatrix | ( | matrix< contents > & | sub, |
int | row, | ||
int | column, | ||
int | rows, | ||
int | cols | ||
) | const |
like submatrix() above, but stores into the "sub" parameter.
Definition at line 236 of file matrix.h.
References structures::matrix< contents >::reset().
matrix< contents > structures::matrix< contents >::transpose |
void structures::matrix< contents >::transpose | ( | matrix< contents > & | resultant | ) | const |
stores the transpose of this matrix in "resultant".
Definition at line 257 of file matrix.h.
References structures::matrix< contents >::reset().
bool structures::matrix< contents >::zap_column | ( | int | column_to_zap | ) |
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, FUNCDEF, and basis::array< contents >::zap().
bool structures::matrix< contents >::zap_row | ( | int | row_to_zap | ) |
Definition at line 288 of file matrix.h.
References bounds_halt, FUNCDEF, and basis::array< contents >::zap().