Array¶
-
class
Array
: public emcore::TypedContainer Four dimensional Array class to manage internal memory and data type.
Subclassed by emcore::Image
Public Functions
-
Array
() Default constructor.
The Array will not have any data associated and the type will be nullptr.
-
Array
(const ArrayDim &adim, const Type &type, void *memory = nullptr) Create an Array by providing dimensions and type. Optionally, the memory address could be provided.
This constructor should be used with care when providing the array memory address. It should be guaranteed that the memory address points to a place allocated for the given number of elements and size specified by ArrayDim and Type.
When providing the memory location, the created array could be seen as an “alias” of another array of a portion of it. In this case, the memory is considered not owned by this Array and it will not be freed.
-
Array
(const Array &other) Copy constructor from another Array. This Array will have the same dimensions, data type and values of the other Array.
- Parameters
other
: Other Array to be copied
-
Array
(Array &&other) Move constructor
-
Array &
operator=
(const Array &other) Assign other Array to this one. This operation will resize the current Array to have the same type and dimensions of the other Array. After the assignment both Array should be equal.
- Return
*this
- Parameters
other
: Other Array from which the elements will be assigned
-
Array &
operator=
(Array &&other) Move assignment
-
void
copy
(const Array &other, const Type &type = typeNull) Copy all the elements from the given array. The calling array will be resized to have the same dimensions of the input array. All elements from the input array will be copied or casted to the output.
- Parameters
other
: Other Array from which the elements will be copiedtype
: If is typeNull, then the current type of the output array will be used. If it is also null, then the input array type will be used.
-
void
patch
(const Array &input, int x = 0, int y = 0, int z = 0) Copy all elements from the input array from a given index. It is assumed that the input array has smaller dimensions than this array. Moreover, the index for start the copy plus the dimensions of the input array, should still be inside this array. Both input array and this array should have proper type and dimensions. This operation is similar to copyTo, but the copy is done from the input array to this array.
- Parameters
input
: Input array, small than this array.x
: X index where to start the copyy
: Y index where to start the copy (default 0)z
: Z index where to start the copy (default 0)
-
void
extract
(const Array &input, int x = 0, int y = 0, int z = 0) Copy all elements from the input array to this one from a given index. It is assumed that this array has smaller dimensions than the input. Moreover, the index for start the copy plus the dimensions of this array should still be inside the input array. Both input array and this array should have proper type and dimensions.
-
void
set
(const Object &value) Assign the value of a single element to the values of the array. If the Array type is the same of the input Object type, then the elements will be copied. If not, they will be casted.
- Return
*this
- Parameters
value
: Input Object with the value that will be assigned
-
Array
getView
(size_t index = 0) Return a View array that share the memory with this one. If index is 0, the new Array will have exactly the same dimensions. If index is between 1 and n, then it will point to a single item but still with the same x, y and z dimensions.
-
void
resize
(const ArrayDim &adim, const Type &type = typeNull) Change the dimensions of the current Array. This operation usually imply a new allocation of memory. Optionally, a new type can be passed. If the current array does not have a type yet, then the input type should be different from typeNull.
-
void
resize
(const Array &other) Resize the array based on the dimensions and the type of the input Array.
-
ArrayDim
getDim
() const Return the current dimensions of the Array
-