100 return data[thesize - 1];
106 return data[thesize - 1];
153 memmove(&(data[i + n]), &(data[i]), (
unsigned int)(j - i) *
sizeof(T));
163 for(
int j = 0; j < n; j++)
174 memcpy(&(data[i]), t, (
unsigned int) n *
sizeof(T));
184 memcpy(&(data[i]), t.
data, (
unsigned int)t.
size() *
sizeof(T));
189 void remove(
int n = 0,
int m = 1)
191 assert(n <
size() && n >= 0);
195 memmove(&(data[n]), &(data[n + m]), (
unsigned int)(
size() - (n + m)) *
sizeof(T));
204 assert(m <=
size() && m >= 0);
228 assert(memFactor >= 1);
231 reMax(
int(memFactor * newsize), newsize);
258 void reMax(
int newMax = 1,
int newSize = -1)
289 memcpy(data, rhs.
data, (
unsigned int)
size() *
sizeof(T));
300 #ifdef ENABLE_CONSISTENCY_CHECKS 304 || (themax < thesize)
306 || (memFactor < 1.0))
316 : thesize(old.thesize)
319 , memFactor(old.memFactor)
323 assert(thesize >= 0);
326 memcpy(data, old.
data, (
unsigned int)thesize *
sizeof(T));
344 thesize = (p_size < 0) ? 0 : p_size;
349 themax = (thesize == 0) ? 1 : thesize;
365 #endif // _DATAARRAY_H_ T & last()
reference last element.
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
bool isConsistent() const
consistency check
Memory allocation routines.
DataArray & operator=(const DataArray &rhs)
assignment operator
T * get_ptr()
get a C pointer to the data.
void clear()
remove all elements.
void insert(int i, int n, const T t[])
insert n elements from t before i 'the element.
T * data
the array of elements
void removeLast(int m=1)
remove m last elements.
void spx_alloc(T &p, int n=1)
Allocate memory.
int thesize
number of used elements in array data
void insert(int i, const DataArray< T > &t)
insert all elements from t before i 'th element.
void append(int n, const T t[])
append n elements from t.
void append(const T &t)
append element t.
int max() const
return maximum number of elements.
const T * get_const_ptr() const
get a const C pointer to the data.
void append(const DataArray< T > &t)
append all elements from t.
int themax
the length of array data and
DataArray(const DataArray &old)
copy constructor
void append(int n, const T &t)
append n elements with value t.
Debugging, floating point type and parameter definitions.
void spx_realloc(T &p, int n)
Change amount of allocated memory.
Everything should be within this namespace.
int size() const
return nr. of elements.
DataArray(int p_size=0, int p_max=0, Real p_fac=1.2)
default constructor.
Real memFactor
memory extension factor.
void insert(int i, int n, const T &t)
insert n elements with value t before i 'the element.
#define MSGinconsistent(name)
void reMax(int newMax=1, int newSize=-1)
reset maximum number of elements.
void insert(int i, int n)
insert n uninitialized elements before i 'th element.
const T & operator[](int n) const
reference n 'th const element.
T & operator[](int n)
reference n 'th element.
void reSize(int newsize)
reset size to newsize.
void spx_free(T &p)
Release memory.
const T & last() const
reference last const element.