From 30f2c9f8003afdf49d439017ca9158879b8d1ae8 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Jan 2010 23:48:43 +0000 Subject: committing changes submitted in patch #2865481 svn path=/trunk/extensions/gripd/; revision=13104 --- src/midiio/include/Array.cpp | 107 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'src/midiio/include/Array.cpp') diff --git a/src/midiio/include/Array.cpp b/src/midiio/include/Array.cpp index 044ed2d..005ed9b 100644 --- a/src/midiio/include/Array.cpp +++ b/src/midiio/include/Array.cpp @@ -22,6 +22,7 @@ #include #include +using namespace std; ////////////////////////////// // @@ -62,8 +63,8 @@ Array::~Array() { } template void Array::setAll(type aValue) { - for (int i=0; igetSize(); i++) { + this->array[i] = aValue; } } @@ -77,8 +78,8 @@ void Array::setAll(type aValue) { template type Array::sum(void) { type theSum = 0; - for (int i=0; igetSize(); i++) { + theSum += this->array[i]; } return theSum; } @@ -87,7 +88,7 @@ template type Array::sum(int loIndex, int hiIndex) { type theSum = 0; for (int i=loIndex; i<=hiIndex; i++) { - theSum += array[i]; + theSum += this->array[i]; } return theSum; } @@ -101,19 +102,19 @@ type Array::sum(int loIndex, int hiIndex) { template void Array::zero(int minIndex, int maxIndex) { - if (size == 0) return; + if (this->size == 0) return; if (minIndex == -1) minIndex = 0; - if (maxIndex == -1) maxIndex = size-1; + if (maxIndex == -1) maxIndex = this->size - 1; if (minIndex < 0 || maxIndex < 0 || minIndex > maxIndex || - maxIndex >= size) { - cerr << "Error in zero function: min = " << minIndex - << " max = " << maxIndex << " size = " << size << endl; + maxIndex >= this->size) { + cerr << "Error in zero function: min = " << minIndex + << " max = " << maxIndex << " size = " << this->size << this->endl; exit(1); } for (int i=minIndex; i<=maxIndex; i++) { - array[i] = 0; + this->array[i] = 0; } } @@ -126,12 +127,12 @@ void Array::zero(int minIndex, int maxIndex) { template int Array::operator==(const Array& aArray) { - if (getSize() != aArray.getSize()) { + if (this->getSize() != aArray.getSize()) { return 0; } Array& t = *this; int i; - for (i=0; igetSize(); i++) { if (t[i] != aArray[i]) { return 0; } @@ -148,20 +149,20 @@ int Array::operator==(const Array& aArray) { template Array& Array::operator=(const Array& anArray) { - if (allocSize < anArray.size) { - if (allocSize != 0) { - delete [] array; + if (this->allocSize < anArray.size) { + if (this->allocSize != 0) { + delete [] this->array; } - allocSize = anArray.size; - size = anArray.size; - array = new type[size]; - allowGrowthQ = anArray.allowGrowthQ; - growthAmount = anArray.growthAmount; - maxSize = anArray.maxSize; + this->allocSize = anArray.size; + this->size = anArray.size; + this->array = new type[this->size]; + this->allowGrowthQ = anArray.allowGrowthQ; + this->growthAmount = anArray.growthAmount; + this->maxSize = anArray.maxSize; } - size = anArray.size; - for (int i=0; isize = anArray.size; + for (int i=0; isize; i++) { + this->array[i] = anArray.array[i]; } return *this; @@ -176,14 +177,14 @@ Array& Array::operator=(const Array& anArray) { template Array& Array::operator+=(const Array& anArray) { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } - for (int i=0; isize; i++) { + this->array[i] += anArray.array[i]; } return *this; @@ -198,8 +199,8 @@ Array& Array::operator+=(const Array& anArray) { template Array Array::operator+(const Array& anArray) const { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } @@ -213,7 +214,7 @@ Array Array::operator+(const Array& anArray) const { template Array Array::operator+(type aNumber) const { Array anArray(*this); - for (int i=0; isize; i++) { anArray[i] += aNumber; } return anArray; @@ -228,14 +229,14 @@ Array Array::operator+(type aNumber) const { template Array& Array::operator-=(const Array& anArray) { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } - for (int i=0; isize; i++) { + this->array[i] -= anArray.array[i]; } return *this; @@ -250,8 +251,8 @@ Array& Array::operator-=(const Array& anArray) { template Array Array::operator-(const Array& anArray) const { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } @@ -265,7 +266,7 @@ Array Array::operator-(const Array& anArray) const { template Array Array::operator-(void) const { Array anArray(*this); - for (int i=0; isize; i++) { anArray[i] = -anArray[i]; } return anArray; @@ -274,7 +275,7 @@ Array Array::operator-(void) const { template Array Array::operator-(type aNumber) const { Array anArray(*this); - for (int i=0; isize; i++) { anArray[i] -= aNumber; } return anArray; @@ -289,14 +290,14 @@ Array Array::operator-(type aNumber) const { template Array& Array::operator*=(const Array& anArray) { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } - for (int i=0; isize; i++) { + this->array[i] *= anArray.array[i]; } return *this; @@ -311,8 +312,8 @@ Array& Array::operator*=(const Array& anArray) { template Array Array::operator*(const Array& anArray) const { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } @@ -326,7 +327,7 @@ Array Array::operator*(const Array& anArray) const { template Array Array::operator*(type aNumber) const { Array anArray(*this); - for (int i=0; isize; i++) { anArray[i] *= aNumber; } return anArray; @@ -339,14 +340,14 @@ Array Array::operator*(type aNumber) const { template Array& Array::operator/=(const Array& anArray) { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } - for (int i=0; isize; i++) { + this->array[i] /= anArray.array[i]; } return *this; @@ -359,8 +360,8 @@ Array& Array::operator/=(const Array& anArray) { template Array Array::operator/(const Array& anArray) const { - if (size != anArray.size) { - cerr << "Error: different size arrays " << size << " and " + if (this->size != anArray.size) { + cerr << "Error: different size arrays " << this->size << " and " << anArray.size << endl; exit(1); } -- cgit v1.2.1