|
latest version v1.9 - last update 24 Nov 2005 |
|
#include <ltiArray.h>
Inheritance diagram for lti::array< T >:


Public Member Functions | |
| array () | |
| array (int from, int to, const T &iniValue=T()) | |
| array (const array< T > &other) | |
| array (const vector< T > &other, int theOffset=0) | |
| array (bool init, int from, int to) | |
| virtual | ~array () |
| virtual const char * | getTypeName () const |
| void | resize (int from, int to, const T &iniValue=T(), bool copyData=true, bool initNew=true) |
| void | shift (int sh) |
| void | fill (const T &data, int from=MinInt32, int to=MaxInt32) |
| int | firstIdx () const |
| void | setFirstIdx (int newIdx) |
| int | lastIdx () const |
| T & | at (int x) |
| const T & | at (int x) const |
| T & | operator[] (int x) |
| const T & | operator[] (int x) const |
| array< T > & | copy (const vector< T > &other) |
| array< T > & | copy (const array< T > &other) |
| array< T > & | operator= (const vector< T > &other) |
| array< T > & | operator= (const array< T > &other) |
| template<class U> | |
| array< T > & | castFrom (const array< U > &other) |
| virtual bool | write (ioHandler &handler, const bool complete=true) const |
| virtual bool | read (ioHandler &handler, const bool complete=true) |
Apply Methods | |
| array< T > & | apply (T(*function)(T)) |
| array< T > & | apply (const array< T > &other, T(*function)(T)) |
| array< T > & | apply (T(*function)(const T &)) |
| array< T > & | apply (const array< T > &other, T(*function)(const T &)) |
| array< T > & | apply (const array< T > &other, T(*function)(const T &, const T &)) |
| array< T > & | apply (const array< T > &other, T(*function)(T, T)) |
| array< T > & | apply (const array< T > &a, const array< T > &b, T(*function)(const T &, const T &)) |
| array< T > & | apply (const array< T > &a, const array< T > &b, T(*function)(T, T)) |
Protected Attributes | |
| int | offset |
| int | firstArrayElement |
| int | lastArrayElement |
| T * | theElement0 |
A n-dimensional array indexed between from and to, where to-from+1 = n. The indices from and to can be negative, but from must be lower or equal to.
All inherited arithmetical operations still need to be reviewed, since the vector methods will only check if the size n of the array is correct. Use these operations at your own risk. It is safer if you use the on-place version of the arithmetical methods, since they won't change the index range of the array. Otherwise, the range will be change to [0,n-1].
|
|||||||||
|
default constructor creates an empty array;
|
|
||||||||||||||||||||
|
constructor.
creates an array indexed between |
|
||||||||||
|
copy constructor.
copy contents of |
|
||||||||||||||||
|
copy constructor.
copy contents of |
|
||||||||||||||||||||
|
If init is true this constructor is equivalent to calling array(int theSize), and thus initializing all elements with T(). However, in some cases the elements need not be initialized during construction, since complex initializion is required. Especially for large arrays, the unnecessary constructor initialization is very time consuming. If init is false, memory is allocated but no initialization takes place.
|
|
|||||||||
|
destructor
|
|
||||||||||||||||||||
|
a two-parameter C-function receives the i-th elements of the given arrays and leaves the result here. Note that both arrays MUST have the same size! If both arrays have different size, the function will throw an assertion without changing anything!
|
|
||||||||||||||||||||
|
a two-parameter C-function receives the i-th elements of the given arrays and leaves the result here. Note that both arrays MUST have the same size! If both arrays have different size, the function will throw an assertion without changing anything! The following example uses lti::min as function. The arrays a and b contain the values [1,2,3,4] and [4,3,2,1], respectively. After applying the function, array c contains the values [1,2,2,1]. iarray a,b,c; int i=0; for (i=0; i<4; ++i) { a.at(i)=i+1; b.at(i)=4-i; } c.apply(a,b,lti::min);
|
|
||||||||||||||||
|
a two-parameter C-function receives the i-th elements of this and the given array and the result will be left in this array. Note that both arrays MUST have the same size! If both arrays have different size, the function will throw an assertion without changing anything!
|
|
||||||||||||||||
|
a two-parameter C-function receives the i-th elements of this and the given array and the result will be left in this array. Note that both arrays MUST have the same size! If both arrays have different size, the function will throw an assertion without changing anything!
|
|
||||||||||||||||
|
applies a C-function to each element the other array and leaves the result here.
|
|
||||||||||
|
applies a C-function to each element of the array.
Reimplemented from lti::genericVector< T >. |
|
||||||||||||||||
|
applies a C-function to each element of the other array and leaves the result here.
|
|
||||||||||
|
applies a C-function to each element of the array. In the following example, array vct is initialized with 4.0. After applying sqrt(), all elements of vct are 2.0.
Reimplemented from lti::genericVector< T >. |
|
||||||||||
|
const access operator. access element x with firstIdx() <= x <= lastIdx(). Reimplemented from lti::genericVector< T >. |
|
||||||||||
|
access operator. access element x with firstIdx() <= x <= lastIdx(). Reimplemented from lti::genericVector< T >. |
|
||||||||||||||
|
cast and copy the elements of the "other" array
|
|
||||||||||
|
assigment operator.
copy content of array |
|
||||||||||
|
assigment operator.
copy content of vector |
|
||||||||||||||||||||
|
fills the array with value
Reimplemented from lti::genericVector< T >. |
|
|||||||||
|
returns first index.
the returned value is equal to Reimplemented from lti::genericVector< T >. |
|
|||||||||
|
returns the name of this type
Reimplemented from lti::vector< T >. Reimplemented in lti::kernel1D< T >, lti::kernel1D< double >, and lti::kernel1D< float >. |
|
|||||||||
|
returns last index.
the returned value is equal to Reimplemented from lti::genericVector< T >. |
|
||||||||||
|
assigment operator. (alias for copy(other). |
|
||||||||||
|
assigment operator. (alias for copy(other). |
|
||||||||||
|
const access operator (alias for at(x))
Reimplemented from lti::genericVector< T >. |
|
||||||||||
|
access operator (alias for at(x)).
Reimplemented from lti::genericVector< T >. |
|
||||||||||||||||
|
read the object from the given ioHandler
Reimplemented from lti::genericVector< T >. Reimplemented in lti::kernel1D< T >, lti::kernel1D< double >, and lti::kernel1D< float >. |
|
||||||||||||||||||||||||||||
|
change the dimension and/or range of the array. If the new dimension of the array (to-from+1) is different from the old one or if this array doesn't own the data, new memory is allocated.
If To adjust the range of an array, i.e. the data contained and the size stays the same, but the start and end indices change, use shift(int). If the new size is not equal to the old size (i.e. to-from+1), the array always owns the data afterwards (i.e. new memory is allocated) even if it didn't own the data before. Otherwise the ownership remains unchanged. You can use restoreOwnership() if you just want to own the data. |
|
||||||||||
|
change the first index of the array, without changing the content
|
|
||||||||||
|
Shift all indices of the array by the given value Negative values result in a left shift, positive values in a right shift. An array with range (-2,2) will have range (0,4) after shift(2) is performed. |
|
||||||||||||||||
|
write the object in the given ioHandler
Reimplemented from lti::genericVector< T >. Reimplemented in lti::kernel1D< T >, lti::kernel1D< double >, and lti::kernel1D< float >. |
|
|||||
|
index of the first element of the array
|
|
|||||
|
index of the last element of the array. if the array is casted to a vector, the "lastIdx()" should return size()-1 instead of the array lastIdx!. That's the reason why we use a new member for the last index in the array! |
|
|||||
|
offset for the 0-th element
|
|
|||||
|
A pointer to the element at index 0 (This allows a faster access than adding the offset each time).
|