netgen/libsrc/general/ngarray.cpp

76 lines
1.6 KiB
C++
Raw Normal View History

2019-07-09 13:41:40 +05:00
#ifndef FILE_NGSTD_NgArrayCPP
#define FILE_NGSTD_NgArrayCPP
2009-01-13 04:40:13 +05:00
// necessary for SGI ????
/**************************************************************************/
/* File: array.cpp */
/* Author: Joachim Schoeberl */
/* Date: 01. Jun. 95 */
/**************************************************************************/
/*
2019-07-09 13:39:16 +05:00
Abstract data type NgArray
2009-01-13 04:40:13 +05:00
*/
#include <mystdlib.h>
#include <myadt.hpp>
#include <assert.h>
namespace netgen
{
//using namespace netgen;
#ifdef NONE
2009-01-25 17:35:25 +05:00
void BASE_Array :: ReSize (int minsize, int elementsize)
2009-01-13 04:40:13 +05:00
{
cout << "resize, minsize = " << minsize << endl;
if (inc == -1)
throw Exception ("Try to resize fixed size array");
void * p;
int nsize = (inc) ? allocsize + inc : 2 * allocsize;
if (nsize < minsize) nsize = minsize;
if (data)
{
p = new char [nsize * elementsize];
int mins = (nsize < actsize) ? nsize : actsize;
memcpy (p, data, mins * elementsize);
delete [] static_cast<char*> (data);
data = p;
}
else
{
data = new char[nsize * elementsize];
}
allocsize = nsize;
cout << "resize done" << endl;
}
2009-01-25 17:35:25 +05:00
void BASE_Array :: RangeCheck (int i) const
2009-01-13 04:40:13 +05:00
{
if (i < 0 || i >= actsize)
throw ArrayRangeException ();
}
2009-01-25 17:35:25 +05:00
void BASE_Array :: CheckNonEmpty () const
2009-01-13 04:40:13 +05:00
{
if (!actsize)
{
2019-07-09 13:39:16 +05:00
throw Exception ("NgArray should not be empty");
// cerr << "NgArray souldn't be empty";
2009-01-13 04:40:13 +05:00
}
}
#endif
}
2019-07-09 13:41:40 +05:00
#endif // FILE_NGSTD_NgArrayCPP
2009-01-13 04:40:13 +05:00