--- ./sources/stack.c.orig Thu Oct 10 12:01:26 1996 +++ ./sources/stack.c Tue Aug 16 23:20:18 2005 @@ -8,77 +8,77 @@ #include "stack.h" -template -Stack:: Stack(int l1, int top1, int h1) - : Vector(l1,top1) { top=top1; h=h1; } - -template -Stack:: Stack(int l1, int top1) - : Vector(l1,top1) { top=top1; h=l1-1; } +template +Stack:: Stack(int l1, int top1, int h1) + : Vector(l1,top1) { top=top1; this->h=h1; } + +template +Stack:: Stack(int l1, int top1) + : Vector(l1,top1) { top=top1; this->h=l1-1; } -template -Stack:: Stack(int top1) : Vector(1,top1) { top=top1; h=0;} +template +Stack:: Stack(int top1) : Vector(1,top1) { top=top1; this->h=0;} -template -Stack:: Stack() : Vector(DefaultSize) { top=DefaultSize; h=0;} +template +Stack:: Stack() : Vector(DefaultSize) { top=DefaultSize; this->h=0;} template void Stack:: push(const T a) { - if (h==top) extend(); - v[++h] = a; + if (this->h==top) extend(); + this->v[++this->h] = a; } template T Stack:: pop() { - if (h < l) + if (this->h < this->l) { - cout << "\n*** pop tried from empty stack \n"; - cout.flush(); abort(); return v[l]; // dummy to avoid compiler warnings + cout << "\n*** pop tried from empty stack \n"; + cout.flush(); abort(); return this->v[this->l]; // dummy to avoid compiler warnings } - else return v[h--]; + else return this->v[this->h--]; } template T Stack:: Top() const { - if (h < l) + if (this->h < this->l) { - cout << "\n*** Class Stack (Top): empty stack \n"; - cout.flush(); abort(); return v[l]; // dummy to avoid compiler warnings + cout << "\n*** Class Stack (Top): empty stack \n"; + cout.flush(); abort(); return this->v[this->l]; // dummy to avoid compiler warnings } - else return v[h]; + else return this->v[this->h]; } template T Stack:: Prev() const { - if (h <= l) + if (this->h <= this->l) { - cout << "\n*** Class Stack (Prev): only one element on stack \n"; - cout.flush(); abort(); return v[l]; // dummy to avoid compiler warnings + cout << "\n*** Class Stack (Prev): only one element on stack \n"; + cout.flush(); abort(); return this->v[this->l]; // dummy to avoid compiler warnings } - else return v[h-1]; + else return this->v[this->h-1]; } template void Stack:: extend() { - int stackSize = top-l+1; + int stackSize = top - this->l + 1; stackSize = int(1.5*stackSize); if (stackSize <= 2) stackSize = 4; - - top = l+stackSize-1; + + top = this->l+stackSize-1; T* vnew = new T[stackSize]; - if (!vnew) + if (!vnew) { - cout << "\n*** stack extension failure: l=" <l; - for (int i=l; i<=h; ++i) vnew[i] = v[i]; - v = v+l; - delete [] v; - v = vnew; + for (int i=this->l; i<=this->h; ++i) vnew[i] = this->v[i]; + this->v = this->v + this->l; + delete [] this->v; + this->v = vnew; if (AnnounceExtensionFlag) cout << "\n* Stack extended to " << top << "\n"; } @@ -86,10 +86,10 @@ template void Stack:: resize(int newl, int newTop) { - v += l; delete[] v; - allocate (newl, newTop); + this->v += this->l; delete[] this->v; + this->allocate (newl, newTop); top = newTop; - h = newl-1; + this->h = newl-1; } template void Stack:: resize(int newTop) { resize (1,newTop); } @@ -97,11 +97,11 @@ template void Stack:: resize(int newl, int newTop, int newh) { resize(newl, newTop); - h = newh; + this->h = newh; } //------------------------------------------------------------------------- template Stack:: Stack(Stack& /*vec*/) { - notImplemented("Stack:: copy constructor! Check function arguments"); + this->notImplemented("Stack:: copy constructor! Check function arguments"); }