24 data =
new char[asize * elementsize];
38 delete [] (
char*)
data;
45 if (nsize < minsize) nsize = minsize;
47 p =
new char[nsize * elementsize];
51 delete [] (
char*)
data;
59 for (
int i = 0; i < size; i++)
62 if ( !((i+1) % width) || i+1 == size )
73 for (
int i = 0; i < size; i++)
74 out <<
operator[](i) <<
'\n';
80 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
82 T max = operator[](0);
83 for (
int i = 1; i < size; i++)
84 if (max <
operator[](i))
93 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
95 T min = operator[](0);
96 for (
int i = 1; i < size; i++)
97 if (
operator[](i) < min)
106 if (*((T*)p) < *((T*)q))
return -1;
107 if (*((T*)q) < *((T*)p))
return +1;
115 qsort(data, size,
sizeof(T), Compare<T>);
122 T sum =
static_cast<T
>(0);
123 for (
int i = 0; i < size; i++)
134 T sum =
static_cast<T
>(0);
135 for (
int i = 0; i < size; i++)
144 T val_prev = operator[](0), val;
145 for (
int i = 1; i < size; i++)
~BaseArray()
Free the allocated memory.
void * data
Pointer to data.
void GrowSize(int minsize, int elementsize)
int size
Size of the array.
void Print(std::ostream &out, int width)
Prints array to stream with width elements per row.
void Sort()
Sorts the array.
int allocsize
Size of the allocated memory.
int IsSorted()
return true if the array is sorted.
void PartialSum()
Partial Sum.
void Save(std::ostream &out)
Prints array to stream out.
int Compare(const void *p, const void *q)