Path: blob/devel/ElmerGUI/netgen/libsrc/general/array.cpp
3206 views
#ifndef FILE_NGSTD_ARRAYCPP1#define FILE_NGSTD_ARRAYCPP2// necessary for SGI ????34/**************************************************************************/5/* File: array.cpp */6/* Author: Joachim Schoeberl */7/* Date: 01. Jun. 95 */8/**************************************************************************/910/*11Abstract data type ARRAY12*/1314#include <mystdlib.h>15#include <myadt.hpp>16#include <assert.h>171819namespace netgen20{21//using namespace netgen;2223#ifdef NONE24void BASE_ARRAY :: ReSize (int minsize, int elementsize)25{26cout << "resize, minsize = " << minsize << endl;2728if (inc == -1)29throw Exception ("Try to resize fixed size array");303132void * p;33int nsize = (inc) ? allocsize + inc : 2 * allocsize;34if (nsize < minsize) nsize = minsize;3536if (data)37{38p = new char [nsize * elementsize];3940int mins = (nsize < actsize) ? nsize : actsize;41memcpy (p, data, mins * elementsize);4243delete [] static_cast<char*> (data);44data = p;45}46else47{48data = new char[nsize * elementsize];49}5051allocsize = nsize;52cout << "resize done" << endl;53}54555657void BASE_ARRAY :: RangeCheck (int i) const58{59if (i < 0 || i >= actsize)60throw ArrayRangeException ();61}6263void BASE_ARRAY :: CheckNonEmpty () const64{65if (!actsize)66{67throw Exception ("Array should not be empty");68// cerr << "Array souldn't be empty";69}70}71#endif72}73#endif74757677