26 #include <type_traits> 67 static_assert(std::is_trivially_copyable<T>::value,
68 "Only trivially copyable types are allowed with DataArray, since it does memcopy");
104 return data[thesize - 1];
110 return data[thesize - 1];
157 memmove(&(data[i + n]), &(data[i]), (
unsigned int)(j - i) *
sizeof(T));
167 for(
int j = 0; j < n; j++)
178 memcpy(&(data[i]), t, (
unsigned int) n *
sizeof(T));
188 memcpy(&(data[i]), t.
data, (
unsigned int)t.
size() *
sizeof(T));
193 void remove(
int n = 0,
int m = 1)
195 assert(n <
size() && n >= 0);
199 memmove(&(data[n]), &(data[n + m]), (
unsigned int)(
size() - (n + m)) *
sizeof(T));
208 assert(m <=
size() && m >= 0);
232 assert(memFactor >= 1);
235 reMax(
int(memFactor * newsize), newsize);
262 void reMax(
int newMax = 1,
int newSize = -1)
293 memcpy(data, rhs.
data, (
unsigned int)
size() *
sizeof(T));
304 #ifdef ENABLE_CONSISTENCY_CHECKS 308 || (themax < thesize)
310 || (memFactor < 1.0))
320 : thesize(old.thesize)
323 , memFactor(old.memFactor)
327 assert(thesize >= 0);
330 memcpy(data, old.
data, (
unsigned int)thesize *
sizeof(T));
348 thesize = (p_size < 0) ? 0 : p_size;
353 themax = (thesize == 0) ? 1 : thesize;
369 #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
Row and columns Id's SPxLP.
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.