#include <Array.h>

Public Types | |
| typedef T * | iterator |
| Pointer to a single array element. | |
| typedef T * | const_iterator |
| Constant pointer to a single array element. | |
Public Member Functions | |
| Array () | |
| Creates a new empty Array object. | |
| Array (unsigned i) | |
| Creates a new empty one-dimensional array of size "i". | |
| Array (unsigned i, unsigned j) | |
| Creates a new empty two-dimensional array. | |
| Array (unsigned i, unsigned j, unsigned k) | |
| Creates a new empty three-dimensional array. | |
| Array (std::vector< T > &v) | |
| Creates a new one-dimensional array with the content of "v". | |
| Array (Array< T > &v, bool) | |
| Creates a new array with the structure and content of array "v". | |
| Array (const Array< T > &v) | |
| Creates a new array with the structure and content of the constant array "v". | |
| ~Array () | |
| Destructs the current Array object. | |
| unsigned int | rows () const |
| Returns the number of rows. | |
| unsigned int | cols () const |
| Returns the number of columns. | |
| T & | operator() () |
| Returns the first and only element of the current array. | |
| const T & | operator() () const |
| Returns the first and only element of the current array as constant. | |
| T & | operator() (unsigned i) |
| Returns the i-th element of the one-dimensional array. | |
| const T & | operator() (unsigned i) const |
| Returns the i-th element of the one-dimensional array as constant. | |
| T & | operator() (unsigned i, unsigned j) |
| Returns the element at position "i" of dimension one and position "j" at dimension two of the two-dimensional array. | |
| const T & | operator() (unsigned i, unsigned j) const |
| Returns the element at position "i" of dimension one and position "j" at dimension two of the two-dimensional array as constant. | |
| T & | operator() (unsigned i, unsigned j, unsigned k) |
| Returns the element at position "i" of dimension one, position "j" at dimension two and position "k" of dimension three of the three-dimensional array. | |
| const T & | operator() (unsigned i, unsigned j, unsigned k) const |
| Returns the element at position "i" of dimension one, position "j" at dimension two and position "k" of dimension three of the three-dimensional array as constant. | |
| T & | operator() (const std::vector< unsigned > &i) |
| Returns the element identified by the dimension-positions in vector "i" from the current array. | |
| const T & | operator() (const std::vector< unsigned > &i) const |
| Returns the element identified by the dimension-positions in vector "i" from the current array as constant. | |
| ArrayReference< T > | operator[] (unsigned i) |
| Returns a reference to subarray "i" of the current array. | |
| const ArrayReference< T > | operator[] (unsigned i) const |
| Returns a constant reference to subarray "i" of the current array. | |
| Array< T > & | operator= (const T &v) |
| Assigns the value "v" to all positions of the current array. | |
| Array< T > & | operator= (const std::vector< T > &v) |
| Assigns the values of vector "v" to the current array. | |
| Array< T > & | operator= (const Array< T > &v) |
| Assigns the values of array "v" to the current array. | |
| T & | elem (unsigned i) |
| Returns the i-th element of the arrays element vector Array::e. | |
| const T & | elem (unsigned i) const |
| Returns the i-th element of the arrays element vector Array::e as constant. | |
| T * | elemvec () |
| Returns the element vector Array::e of the array. | |
| const T * | elemvec () const |
| Returns the element vector Array::e of the array as constant. | |
| Array< T > & | append_elem (const T &w) |
| Appends value "w" to the current one-dimensional or empty array. | |
| Array< T > & | append_elems (const Array< T > &w) |
| Appends the values in "w" to the current one-dimensional or empty array. | |
| Array< T > & | append_rows (const Array< T > &y) |
| Appends the array "y" after the last row of the current array. | |
| Array< T > & | remove_row (unsigned i) |
| Removes row "i" from the current non-empty array. | |
| Array< T > | remove_col (unsigned k) const |
| Removes column "k" from the current non-empty array. | |
| Array< T > & | remove_cols (const Array< unsigned > idx) |
| Removes the columns with the indices stored in array "idx" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j) |
| Removes the two columns with the indices "i" and "j" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k) |
| Removes the three columns with the indices "i", "j" and "k" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k, unsigned l) |
| Removes the four columns with the indices "i", "j", "k" and "l" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m) |
| Removes the five columns with the indices "i", "j", "k", "l" and "m" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n) |
| Removes the six columns with the indices "i", "j", "k", "l", "m" and "n" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o) |
| Removes the seven columns with the indices "i", "j", "k", "l", "m", "n" and "o" from the current non-empty array. | |
| Array< T > & | remove_cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o, unsigned p) |
| Removes the eight columns with the indices "i", "j", "k", "l", "m", "n", "o" and "p" from the current non-empty array. | |
| Array< T > | append_cols (const Array< T > &y) const |
| Appends the array "y" after the last column of the current array. | |
| Array< T > | subarr (unsigned from, unsigned to) const |
| Returns a subarray from position "from" to position "to" of the current array. | |
| Array< unsigned > | pos2idx (unsigned p) |
| Given an absolute position "p" in the element vector Array::e, the positions relative to the single dimensions of the array are returned. | |
| void | pos2idx (unsigned p, Array< unsigned > &idx) |
| Given an absolute position "p" in the element vector Array::e, the positions relative to the single dimensions are stored in "idx". | |
| Array< T > | row (unsigned i) const |
| Returns the row number "i" of the current array. | |
| Array< T > | rows (const Array< unsigned > &idx) const |
| Returns the array rows with the numbers defined in array "idx" from the current non-empty array. | |
| Array< T > | rows (unsigned i) const |
| Returns the array row number "i" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j) const |
| Returns the array rows with the numbers "i" and "j" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k) const |
| Returns the array rows with the numbers "i", "j" and "k" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k, unsigned l) const |
| Returns the array rows with the numbers "i", "j", "k" and "l" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m) const |
| Returns the array rows with the numbers "i", "j", "k", "l" and "m" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n) const |
| Returns the array rows with the numbers "i", "j", "k", "l", "m" and "n" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o) const |
| Returns the array rows with the numbers "i", "j", "k", "l", "m", "n" and "o" from the current non-empty array. | |
| Array< T > | rows (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o, unsigned p) const |
| Returns the array rows with the numbers "i", "j", "k", "l", "m", "n", "o" and "p" from the current non-empty array. | |
| Array< T > | col (unsigned i) const |
| Returns the column number "i" of the current array. | |
| Array< T > | cols (const Array< unsigned > &idx) const |
| Returns the array columns with the numbers defined in array "idx" from the current non-empty array. | |
| Array< T > | cols (unsigned i) const |
| Returns the array column number "i" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j) const |
| Returns the array columns with the numbers "i" and "j" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k) const |
| Returns the array columns with the numbers "i", "j" and "k" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k, unsigned l) const |
| Returns the array columns with the numbers "i", "j", "k" and "l" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m) const |
| Returns the array columns with the numbers "i", "j", "k", "l" and "m" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n) const |
| Returns the array columns with the numbers "i", "j", "k", "l", "m" and "n" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o) const |
| Returns the array columns with the numbers "i", "j", "k", "l", "m", "n" and "o" from the current non-empty array. | |
| Array< T > | cols (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m, unsigned n, unsigned o, unsigned p) const |
| Returns the array columns with the numbers "i", "j", "k", "l", "m", "n", "o" and "p" from the current non-empty array. | |
| Array< T > & | transpose () |
| Returns the transposition of the current array. | |
| Array< T > & | rotate_rows (int n) |
| The last "n" rows of the array will become the first rows. | |
| Array< T > & | rotate_cols (int n) |
| The last "n" columns of the array will become the first columns. | |
| Array< unsigned > | dimarr () const |
| Returns an array that has the same content as the dimension vector ArrayBase::d of the current Array object. | |
| ArrayBase * | clone () const |
| Returns an identical copy of this Array object. | |
| ArrayBase * | empty () const |
| Returns an empty array with the same type as this array object. | |
| iterator | begin () |
| Returns an iterator to the first array element. | |
| const const_iterator | begin () const |
| Returns a constant iterator to the first array element. | |
| iterator | end () |
| Returns an iterator to the last array element. | |
| const const_iterator | end () const |
| Returns a constant iterator to the last array element. | |
Protected Member Functions | |
| void | resize_i (unsigned *_d, unsigned _nd, bool copy) |
| Handles memory allocation for the other resize methods. | |
| Array (unsigned *_d, T *_e, unsigned _nd, unsigned _ne, bool _stat) | |
| Creates a new Array object with the structure and content given by the parameters. | |
Protected Attributes | |
| T * | e |
| The element vector of the current array. | |
| T * | eEnd |
| The last element of the element vector Array::e. | |
Friends | |
| class | ArrayReference< T > |
| class | ArrayIndex |
The class is derived from class ArrayBase.
Here you will find element-specific methods for access of elements, assigning elements, adding and removing elements, changing the order of elements and resizing arrays.
Definition at line 988 of file Array.h.
| typedef T* Array< T >::const_iterator |
Creates a new empty three-dimensional array.
Memory for an
array is allocated.
| i | size of the first dimension of the new array | |
| j | size of the second dimension of the new array | |
| k | size of the third dimension of the new array |
Creates a new array with the structure and content of array "v".
| v | array, whose content will be content of the new array, the content of v will be deleted and v will act as static reference to the new created array | |
| ... | dummy value |
Destructs the current Array object.
Deletes the dimension and element vector Array::e and frees the corresponding memory.
| Array< T >::Array | ( | unsigned * | _d, | |
| T * | _e, | |||
| unsigned | _nd, | |||
| unsigned | _ne, | |||
| bool | _stat | |||
| ) | [inline, protected] |
Creates a new Array object with the structure and content given by the parameters.
A new Array is created by using the parameterized values for the internal structure and content.
This method is for internal use only.
| _d | one-dimensional vector of array-dimensions | |
| _e | one-dimensional vector of array elements for all dimensions | |
| _nd | number of array-dimensions | |
| _ne | total number of array elements | |
| _stat | defines, whether the array object is a static reference or not |
| const const_iterator Array< T >::begin | ( | ) | const [inline] |
Returns a constant iterator to the first array element.
A constant pointer to the first element of the element vector Array::e of the current array is returned as iterator.
This method is used for compatibility with the other stdlib structures.
Returns an iterator to the first array element.
A pointer to the first element of the element vector Array::e of the current array is returned as iterator.
This method is used for compatibility with the other stdlib structures.
Definition at line 4252 of file Array.h.
Referenced by operator==(), and Array< T * >::remove_cols().
| const T* Array< T >::elemvec | ( | ) | const [inline] |
| T* Array< T >::elemvec | ( | ) | [inline] |
Returns the element vector Array::e of the array.
Definition at line 1831 of file Array.h.
Referenced by Array< T * >::append_cols(), Array< T * >::append_rows(), Array< T * >::col(), Array< T * >::cols(), ArrayTable< T >::operator T **(), ArrayTable< T >::operator T ***(), Array< T * >::remove_col(), Array< T * >::remove_row(), Array< T * >::rows(), and Array< T * >::subarr().
Returns an empty array with the same type as this array object.
A new empty Array object with the same type as the current array is created and a pointer to this new object returned.
Implements ArrayBase.
| const const_iterator Array< T >::end | ( | ) | const [inline] |
Returns a constant iterator to the last array element.
A constant pointer to the last element of the element vector Array::e of the current array is returned as iterator.
This method is used for compatibility with the other stdlib structures.
Returns an iterator to the last array element.
A constant pointer to the last element of the element vector Array::e of the current array is returned as iterator.
This method is used for compatibility with the other stdlib structures.
Definition at line 4305 of file Array.h.
Referenced by operator==(), and Array< T * >::remove_cols().
Given an absolute position "p" in the element vector Array::e, the positions relative to the single dimensions are stored in "idx".
| p | the absolute position | |
| idx | an array with the relative positions |
| SharkException | the type of the exception will be "range check error" and indicates that p exceeds the number of elements of the current array |
array, i.e. an array with a total number of 20 elements. You want to extract the element at the absolute position 13 of the element vector (containing elements with indices 0 to 19).
, because
.| void Array< T >::resize_i | ( | unsigned * | _d, | |
| unsigned | _nd, | |||
| bool | copy | |||
| ) | [inline, protected, virtual] |
Handles memory allocation for the other resize methods.
This function handles memory allocation of the respective template type in case of resizing and is only for internal use.
| _d | one-dimensional vector of array-dimensions | |
| _nd | number of array-dimensions | |
| copy | flag which indicates whether existing elements of an array should be copied in case of resizing (as long as possible) |
| SharkException | the type of the exception is "size mismatch" and indicates, that the current array is a static array reference. You can't change the size of an array reference, so it is checked, if the current number of dimensions is not equal to the new defined number of dimensions _nd and if the current total number of array elements is not equal to the new number of array elements. If the preprocessor directive "-DNDEBUG" is not used, then it is also checked, if at least one of the sizes of the single dimensions of the current array (reference) is not equal to the corresponding new defined size in _d. Both cases are illegal for static array references, so the exception is thrown. So the only chance to use this method on static array references is to change nothing, i.e. the new number of dimensions and dimension sizes are equal to the old ones (what makes not a real sense at all). |
Implements ArrayBase.
Definition at line 4460 of file Array.h.
Referenced by Array< T * >::append_cols(), Array< T * >::col(), Array< T * >::cols(), Array< T * >::remove_col(), Array< T * >::remove_row(), Array< T * >::rows(), and Array< T * >::subarr().
The last "n" columns of the array will become the first columns.
| n | number of last columns that will become the n first columns |
| SharkException | the type of the exception will be "size mismatch" and indicates that the current array has no dimensions |

and
then the returned array will be

The last "n" rows of the array will become the first rows.
| n | number of last rows that will become the n first rows |
| SharkException | the type of the exception will be "size mismatch" and indicates that the current array has no dimensions |

and
then the returned array will be

friend class ArrayReference< T > [friend] |
The element vector of the current array.
Internally, the major information about an array is stored in two vectors, the element vector and the dimension vector ArrayBase::d.
The element vector stores all single elements of an array successively. Beginning with the first position in the first dimension of an array as seen by the user, go recursively down to the last dimension and list all elements there.
This will give you the order of the elements in the element vector.
#include "Array/Array.h" void main() { Array< unsigned > test( 2, 2, 4 ); // 3-dimensional test array unsigned *evec, // element vector no_elems, // total number of array // elements curr_no; // number of current element // Fill test array with cotent: test( 0, 0, 0 ) = 1; test( 0, 0, 1 ) = 2; test( 0, 0, 2 ) = 3; test( 0, 0, 3 ) = 4; test( 0, 1, 0 ) = 5; test( 0, 1, 1 ) = 6; test( 0, 1, 2 ) = 7; test( 0, 1, 3 ) = 8; test( 1, 0, 0 ) = 9; test( 1, 0, 1 ) = 10; test( 1, 0, 2 ) = 11; test( 1, 0, 3 ) = 12; test( 1, 1, 0 ) = 13; test( 1, 1, 1 ) = 14; test( 1, 1, 2 ) = 15; test( 1, 1, 3 ) = 16; // Get total number of array elements: no_elems = test.nelem( ); // Get element vector, output of each vector element: for ( curr_no = 0, evec = test.elemvec( ); curr_no < no_elems; curr_no++, evec++ ) { cout << *evec << ' '; } }

Definition at line 4410 of file Array.h.
Referenced by Array< T * >::append_elems(), Array< T * >::Array(), ArrayReference< T >::copyReference(), Array< T * >::operator=(), and Array< T >::operator[]().