PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
Class_Array.cpp
1 #include "Class_Array.hpp"
2 
3 Class_Array::Class_Array() {
4  // TODO Auto-generated constructor stub
5  arraySize = 0;
6  array = NULL;
7 }
8 
9 Class_Array::Class_Array(uint32_t size, int value) {
10 
11  arraySize = size;
12  array = new int [size];
13  for(uint32_t i = 0; i < size; ++i)
14  array[i] = value;
15 }
16 
17 Class_Array::Class_Array(
18  const Class_Array& other) {
19  arraySize = other.arraySize;
20  // if(array != NULL){
21  // delete [] array;
22  // array = NULL;
23  // }
24  array = new int [arraySize];
25  for(uint32_t i = 0; i < arraySize; ++i)
26  array[i] = other.array[i];
27 }
28 
29 Class_Array::~Class_Array() {
30  // delete [] array;
31  // array = NULL;
32 }
33 
34 Class_Array& Class_Array::operator =(
35  const Class_Array& rhs) {
36  if(this != &rhs)
37  {
38  int* new_array = new int[rhs.arraySize];
39  copy(rhs.array,rhs.array+rhs.arraySize,new_array);
40 
41  delete [] array;
42 
43  array = new_array;
44  arraySize = rhs.arraySize;
45  }
46  return *this;
47 }
Customized array definition.
Definition: Class_Array.hpp:37