1 #ifndef __SimpleArray_h__
2 #define __SimpleArray_h__
64 for(
size_t n=0; n<
size; n++){
78 memcpy((
void*)destination.
data, (
void*)
data,
size*
sizeof(T));
88 memcpy((
void*)
data, (
void*)source.
data, source.
size*
sizeof(T));
100 insert(source, 0, destinationOffset, len);
112 ASSERT(
size >= destinationOffset+len,
"Array too small");
113 ASSERT(source.
size >= sourceOffset+len,
"Array too small");
114 memcpy((
void*)(
data+destinationOffset), (
void*)(source.
data+sourceOffset), len*
sizeof(T));
124 void move(
int fromIndex,
int toIndex,
size_t len){
125 ASSERT(
size >= toIndex+len,
"Array too small");
126 memmove((
void*)(
data+toIndex), (
void*)(
data+fromIndex), len*
sizeof(T));
134 static void copy(T* dst, T* src,
size_t len){
135 size_t blocks = len >> 2u;
SimpleArray holds a pointer to an array and the array size, and is designed to be passed by value.
SimpleArray(T *data, size_t size)
void copyFrom(SimpleArray< T > source)
Copies the content of another array into this array.
bool equals(const SimpleArray< T > &other) const
Compares two arrays.
void insert(SimpleArray< T > source, int destinationOffset, size_t len)
Copies the content of an array into a subset of the array.
void copyTo(SimpleArray< T > destination)
Copies the content of this array to another array.
void insert(SimpleArray< T > source, int sourceOffset, int destinationOffset, size_t len)
Copies the content of an array into a subset of the array.
void setElement(size_t index, T value)
Set a single value in the array.
static void copy(T *dst, T *src, size_t len)
Optimised array copy for datatype T.
T * getData()
Get the data stored in the Array.
void move(int fromIndex, int toIndex, size_t len)
Copies values within an array.
T getElement(size_t index)
Get a single value stored in the array.
#define ASSERT(cond, msg)