Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/general/array.cpp
3206 views
1
#ifndef FILE_NGSTD_ARRAYCPP
2
#define FILE_NGSTD_ARRAYCPP
3
// necessary for SGI ????
4
5
/**************************************************************************/
6
/* File: array.cpp */
7
/* Author: Joachim Schoeberl */
8
/* Date: 01. Jun. 95 */
9
/**************************************************************************/
10
11
/*
12
Abstract data type ARRAY
13
*/
14
15
#include <mystdlib.h>
16
#include <myadt.hpp>
17
#include <assert.h>
18
19
20
namespace netgen
21
{
22
//using namespace netgen;
23
24
#ifdef NONE
25
void BASE_ARRAY :: ReSize (int minsize, int elementsize)
26
{
27
cout << "resize, minsize = " << minsize << endl;
28
29
if (inc == -1)
30
throw Exception ("Try to resize fixed size array");
31
32
33
void * p;
34
int nsize = (inc) ? allocsize + inc : 2 * allocsize;
35
if (nsize < minsize) nsize = minsize;
36
37
if (data)
38
{
39
p = new char [nsize * elementsize];
40
41
int mins = (nsize < actsize) ? nsize : actsize;
42
memcpy (p, data, mins * elementsize);
43
44
delete [] static_cast<char*> (data);
45
data = p;
46
}
47
else
48
{
49
data = new char[nsize * elementsize];
50
}
51
52
allocsize = nsize;
53
cout << "resize done" << endl;
54
}
55
56
57
58
void BASE_ARRAY :: RangeCheck (int i) const
59
{
60
if (i < 0 || i >= actsize)
61
throw ArrayRangeException ();
62
}
63
64
void BASE_ARRAY :: CheckNonEmpty () const
65
{
66
if (!actsize)
67
{
68
throw Exception ("Array should not be empty");
69
// cerr << "Array souldn't be empty";
70
}
71
}
72
#endif
73
}
74
#endif
75
76
77