template for an array with well defined number of elements More...
#include <fixArray.h>
Public Member Functions | |
| fixArray () | |
| default constructor | |
| virtual | ~fixArray () |
| virtual destructor | |
| unsigned int | size () |
| returns the max. number of elements in this array | |
| unsigned int | count () |
| returns the number of used elements in this array | |
| type & | getAt (const unsigned int index, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| returns the reference to the member at index (0-based) | |
| int | setAt (const unsigned int index, const type &elem, BM_STATUS elementStatus=0) |
| copies the content of elem into the element in the array at index (0-based) | |
| type & | operator[] (const unsigned int index) |
| returns the reference of the element at index (0-based) | |
| int | find (type &elem, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| looks for a same element in the array | |
| bool | isEmpty (unsigned int *index=(unsigned int *) 0) |
| checks if the array is empty (all status == undef) | |
| type & | first (unsigned int &iterateIndex, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| returns the element at index 0 | |
| type & | next (unsigned int &iterateIndex, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| returns the next element of iterateIndex (roll over index 0) | |
| type & | prev (unsigned int &iterateIndex, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| returns the previous element of iterateIndex (roll over index 0) | |
| type & | last (unsigned int &iterateIndex, BM_STATUS *elementStatus=(BM_STATUS *) 0) |
| returns the last element (at index maxElements-1) | |
| int | isSubset (const fixArray &superSet) |
| returns 0 if all elements of this array are in the array superSet | |
| int | isEqual (const fixArray &set) |
| returns 0 if all elements of this array are in the array superSet and visa verse | |
| int | assignSortAscendant () |
| sorts this array in ascendant order. The result is this array. | |
| fixArray & | assignOverlap (const fixArray &set2) |
| makes all elements in this array undef which are not in set2 | |
| int | overlap (fixArray &result, const fixArray &set2) const |
| returns in result all elements which are in both arrays. | |
| int | assignConcatenate (const fixArray &set2) |
| returns in this array all elements of both arrays (concatenate). | |
| int | concatenate (fixArray &result, const fixArray &set2) const |
| returns in result all elements of both arrays (concatenate). | |
| int | notInSet (fixArray &result, const fixArray &set2) const |
| returns in result all elements of this array which are not in set2. | |
Public Attributes | |
| type | errElement |
| an error element of same data type | |
| type | element [maxElements] |
| the elements | |
| BM_STATUS | bms [maxElements] |
| basic math status of each element | |
template for an array with well defined number of elements
acces to the members of the array are safe. If the index into the array is out of bounds you receive an error element. All well known functionalities on arrays are implemented e.g. operator [](), find(), setAt(), getAt(), isEmpty(), ...
| type | data type of an element. This can be a simple data type like int or double but also typedefs and classes are allowed. | |
| maxElements | max. number of elements in the array |
fixArray<double, 3> xyz; //same as double xyz[3]; fixArray<fpv, 3> fpv_xyz; //same as fpv fpv_xyz[3];
default constructor
creates an array of maxElements of data type.
If you create this class on the stack, the elements are also on the stack.
If you create this class on the heap, the elements are also on the heap.
fixArray<double, 3> xyz; //same as double xyz[3]; fixArray<fpv, 3> fpv_xyz; //same as fpv fpv_xyz[3];
| virtual fixArray< type, maxElements >::~fixArray | ( | ) | [inline, virtual] |
virtual destructor
The elements will be destroyed.
| int fixArray< type, maxElements >::assignConcatenate | ( | const fixArray< type, maxElements > & | set2 | ) | [inline] |
returns in this array all elements of both arrays (concatenate).
all elements from set2 will be appended. Elements which are undef will be ignored.
| set2 | [in] the elements to be appended into this array |
| fixArray& fixArray< type, maxElements >::assignOverlap | ( | const fixArray< type, maxElements > & | set2 | ) | [inline] |
makes all elements in this array undef which are not in set2
Elements which are undef will be ignored. This function uses find() to compare this elements with set2.elements
| set2 | [in] the elements to be compared with this->elements |
| int fixArray< type, maxElements >::assignSortAscendant | ( | ) | [inline] |
sorts this array in ascendant order. The result is this array.
Elements which are undef will be sorted to the end of the array. This function uses Compare() to sort the elements
| int fixArray< type, maxElements >::concatenate | ( | fixArray< type, maxElements > & | result, | |
| const fixArray< type, maxElements > & | set2 | |||
| ) | const [inline] |
returns in result all elements of both arrays (concatenate).
First all elements from this array will be copied. Then all elements from set2 will be copied into result. Elements which are undef will be ignored.
| result | [out] the result of this method | |
| set2 | [in] the elements to be added |
| unsigned int fixArray< type, maxElements >::count | ( | ) | [inline] |
returns the number of used elements in this array
use size() to retrieve the total number of elements in this array
| int fixArray< type, maxElements >::find | ( | type & | elem, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
looks for a same element in the array
and returns the zero based index into the array if an equal element is found
| elem | the element to be searched for | |
| elementStatus | [out,opt] (can be null) A pointer to receive also basic math status informations of the found element. |
| type& fixArray< type, maxElements >::first | ( | unsigned int & | iterateIndex, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
returns the element at index 0
| iterateIndex | [out] the index of the returned element (here 0). This index can be used for next() and prev() | |
| elementStatus | [out,opt] (can be null) A pointer to receive also basic math status informations of the returned element. |
| type& fixArray< type, maxElements >::getAt | ( | const unsigned int | index, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
returns the reference to the member at index (0-based)
if index is out of bound (index >= maxElements) the reference to errElement will be returned.
| index | the zero based index into this array to the element to be received | |
| elementStatus | [out,opt] A pointer to receive basic math status informations (can be null). elementStatus remains unchanged if there is no error in this operation. elementStatus acts accumulative. |
| bool fixArray< type, maxElements >::isEmpty | ( | unsigned int * | index = (unsigned int*)0 |
) | [inline] |
checks if the array is empty (all status == undef)
and returns true if all array elements are undef
| index | [out,opt] pointer to receive the index of the first defined element. |
| int fixArray< type, maxElements >::isEqual | ( | const fixArray< type, maxElements > & | set | ) | [inline] |
returns 0 if all elements of this array are in the array superSet and visa verse
| set | [in] the array in which this array searches for all its elements and the elements of set will be searched in this array. |
| int fixArray< type, maxElements >::isSubset | ( | const fixArray< type, maxElements > & | superSet | ) | [inline] |
returns 0 if all elements of this array are in the array superSet
the order of the elements is ignored.
| superSet | [in] the array in which this array searches for all its elements |
| type& fixArray< type, maxElements >::last | ( | unsigned int & | iterateIndex, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
returns the last element (at index maxElements-1)
| iterateIndex | [out] the index of the returned element (here maxElements-1). This index can be used for next() and prev() | |
| elementStatus | [out,opt] (can be null) A pointer to receive also basic math status informations of the returned element. |
| type& fixArray< type, maxElements >::next | ( | unsigned int & | iterateIndex, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
returns the next element of iterateIndex (roll over index 0)
for roll over see parameter iterateIndex
| iterateIndex | [in,out] [in] zero based index of the last received element (can be >= maxElements) [out] the index of the returned element. This index can be used for next() and prev() Hint: if iterateIndex will be maxElements we rolled over the bounds of the array. In this case element[0] was returned (maxElements % maxElements = 0). | |
| elementStatus | [out,opt] (can be null) A pointer to receive also basic math status informations of the returned element. |
| int fixArray< type, maxElements >::notInSet | ( | fixArray< type, maxElements > & | result, | |
| const fixArray< type, maxElements > & | set2 | |||
| ) | const [inline] |
returns in result all elements of this array which are not in set2.
Elements which are undef will be ignored.
| result | [out] the result of this method | |
| set2 | [in] the elements excluded from result |
| type& fixArray< type, maxElements >::operator[] | ( | const unsigned int | index | ) | [inline] |
returns the reference of the element at index (0-based)
if index is out of bound (index >= maxElements) the reference to errElement will be returned.
| index | the zero based index into this array to the element to be received |
| int fixArray< type, maxElements >::overlap | ( | fixArray< type, maxElements > & | result, | |
| const fixArray< type, maxElements > & | set2 | |||
| ) | const [inline] |
returns in result all elements which are in both arrays.
Elements which are undef will be ignored. This function uses find() to compare this elements with set2.elements
| result | [out] the result of this method | |
| set2 | [in] the elements to be compared with this->elements |
| type& fixArray< type, maxElements >::prev | ( | unsigned int & | iterateIndex, | |
| BM_STATUS * | elementStatus = (BM_STATUS*)0 | |||
| ) | [inline] |
returns the previous element of iterateIndex (roll over index 0)
for roll over see parameter iterateIndex
| iterateIndex | [in,out] [in] zero based index of the last received element (can be >= maxElements) [out] the index of the returned element. This index can be used for next() and prev(). Hint: iterateIndex will be 2*maxElements -1 if we rolled over bounds. In this case element[maxElements-1] was returned. | |
| elementStatus | [out,opt] (can be null) A pointer to receive also basic math status informations of the returned element. |
| int fixArray< type, maxElements >::setAt | ( | const unsigned int | index, | |
| const type & | elem, | |||
| BM_STATUS | elementStatus = 0 | |||
| ) | [inline] |
copies the content of elem into the element in the array at index (0-based)
if index is out of bound (index >= maxElements) -1 will be returned and nothing is copied
| index | the zero based index into this array to the element to be set | |
| elem | reference to the element which content will be copied into the element in the array at index | |
| elementStatus | [in,opt] basic math status informations to be set for this element. |
| unsigned int fixArray< type, maxElements >::size | ( | ) | [inline] |
returns the max. number of elements in this array
use count() to retrieve the number of used elements in this array
| type fixArray< type, maxElements >::errElement |
an error element of same data type
the reference to this error element will be returned if the index of a member function exceeded (index >= maxElements)
1.6.3