From 62f7acd88465f4f20b9b25c3f7edd4e3b7ce453b Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Mon, 19 Sep 2016 11:36:10 -0600 Subject: rm template.c --- omegalib/omega/include/basic/DynamicArray.c | 219 ---------------------------- 1 file changed, 219 deletions(-) delete mode 100644 omegalib/omega/include/basic/DynamicArray.c (limited to 'omegalib/omega/include/basic/DynamicArray.c') diff --git a/omegalib/omega/include/basic/DynamicArray.c b/omegalib/omega/include/basic/DynamicArray.c deleted file mode 100644 index 8ede2f7..0000000 --- a/omegalib/omega/include/basic/DynamicArray.c +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include - -namespace omega { - -template void DynamicArray::do_constr() - { -// #if ! defined SHUT_UP_ABOUT_STATEMENT_WITH_NO_EFFECT_IN_DYNAMIC_ARRAY_CREATION -// assert(d > 0); -// #endif - bounds = 0; - elements = 0; - partial = false; - } - - -template void DynamicArray1::do_construct(int d0) - { - this->bounds = new int[1]; - this->bounds[0] = d0; - this->elements = new T [d0]; - this->partial = false; - } - -template void DynamicArray2::do_construct(int d0, int d1) - { - this->bounds = new int[2]; - this->bounds[0] = d0; - this->bounds[1] = d1; - this->elements = new T [d0 * d1]; - this->partial = false; - } - -template void DynamicArray3::do_construct(int d0,int d1,int d2) - { - this->bounds = new int[3]; - this->bounds[0] = d0; - this->bounds[1] = d1; - this->bounds[2] = d2; - this->elements = new T [d0 * d1 * d2]; - this->partial = false; - } - -template void DynamicArray4::do_construct(int d0,int d1,int d2,int d3) - { - this->bounds = new int[4]; - this->bounds[0] = d0; - this->bounds[1] = d1; - this->bounds[2] = d2; - this->bounds[3] = d3; - this->elements = new T [d0 * d1 * d2 * d3]; - this->partial = false; - } - -template DynamicArray::DynamicArray() - { - do_constr(); - } - -template DynamicArray1::DynamicArray1(const char *) - { - this->do_constr(); - } - -template DynamicArray2::DynamicArray2(const char *,const char *) - { - this->do_constr(); - } - -template DynamicArray3::DynamicArray3(const char *,const char *,const char *) - { - this->do_constr(); - } - -template DynamicArray4::DynamicArray4(const char *,const char *,const char *,const char *) - { - this->do_constr(); - } - -template DynamicArray1::DynamicArray1(int d0) - { - do_construct(d0); - } - -template DynamicArray2::DynamicArray2(int d0, int d1) - { - do_construct(d0, d1); - } - -template DynamicArray3::DynamicArray3(int d0,int d1,int d2) - { - do_construct(d0, d1, d2); - } - -template DynamicArray4::DynamicArray4(int d0,int d1,int d2,int d3) - { - do_construct(d0, d1, d2, d3); - } - - -template void DynamicArray::do_destruct() - { - if (! partial) - { - delete [] bounds; - delete [] elements; - } - } - - -template DynamicArray::~DynamicArray() - { - do_destruct(); - } - - -template void DynamicArray1::resize(int d0) - { - assert(!this->partial); - this->do_destruct(); - if (d0 == 0) - this->do_constr(); - else - do_construct(d0); - } - -template void DynamicArray2::resize(int d0, int d1) - { - assert(!this->partial); - this->do_destruct(); - if (d0 == 0 && d1 == 0) - this->do_constr(); - else - do_construct(d0, d1); - } - -template void DynamicArray3::resize(int d0, int d1, int d2) - { - assert(!this->partial); - this->do_destruct(); - if (d0 == 0 && d1 == 0 && d2 == 0) - this->do_constr(); - else - do_construct(d0, d1, d2); - } - -template void DynamicArray4::resize(int d0, int d1, int d2, int d3) - { - assert(!this->partial); - this->do_destruct(); - if (d0 == 0 && d1 == 0 && d2 == 0 && d3 == 0) - this->do_constr(); - else - do_construct(d0, d1, d2, d3); - } - - -template T& DynamicArray1::operator[](int d0) - { -#if !defined (NDEBUG) - assert(this->elements != 0 && "Trying to dereference undefined array"); - assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds"); -#endif - - return this->elements[d0]; - } - -template DynamicArray1 DynamicArray2::operator[](int d0) - { -#if !defined (NDEBUG) - assert(this->elements != 0 && "Trying to dereference undefined array"); - assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds"); -#endif - - DynamicArray1 result; - result.bounds = this->bounds+1; - result.elements = this->elements + this->bounds[1] * d0; - result.partial = true; - return result; - } - -template DynamicArray2 DynamicArray3::operator[](int d0) - { -#if !defined (NDEBUG) - assert(this->elements != 0 && "Trying to dereference undefined array"); - assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds"); -#endif - DynamicArray2 result; - result.bounds = this->bounds+1; - result.elements = this->elements + this->bounds[1] * this->bounds[2] * d0; - result.partial = true; - return result; - } - -template DynamicArray3 DynamicArray4::operator[](int d0) - { -#if !defined (NDEBUG) - assert(this->elements != 0 && "Trying to dereference undefined array"); - assert(0 <= d0 && d0 < this->bounds[0] && "Array subscript out of bounds"); -#endif - - DynamicArray3 result; - result.bounds = this->bounds+1; - result.elements = this->elements + this->bounds[1] * this->bounds[2] * this->bounds[3] * d0; - result.partial = true; - return result; - } - - -template - DynamicArray::DynamicArray(DynamicArray &D) - { - assert(D.elements != 0 && "Trying to copy an undefined array"); - partial = true; - bounds = D.bounds; - elements = D.elements; - } - -} // namespace -- cgit v1.2.3-70-g09d2