From 2ac9ab5d5f8c7be34b5a8c716c6a835821f71290 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 6 Feb 1997 11:01:09 +0000 Subject: [PATCH] flower-1.0.25 --- flower/NEWS | 7 ++++++- flower/varray.hh | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/flower/NEWS b/flower/NEWS index 77591bb6cb..aac5b758ff 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,4 +1,9 @@ + +pl 25 + - merge sstack and Array +pl 24 + - small fix in vector print pl 23 - win32 patches (JN) -pl 22: +pl 22 - Array::add -> Array::push \ No newline at end of file diff --git a/flower/varray.hh b/flower/varray.hh index 40e76a3dc7..229fdf3c45 100644 --- a/flower/varray.hh +++ b/flower/varray.hh @@ -15,7 +15,7 @@ inline void arrcpy(T*dest, T*src, int count) { *dest++ = *src++; } -///scaleable array template, for T with def ctor. +///scaleable array/stack template, for T with def ctor. template class Array { protected: @@ -99,17 +99,23 @@ public: // vars thearray[size_++] = x; } - - /// junk last entry. - void pop() { size_ -- ; } - - /// return last entry - T& last(int j=0) { + /// remove and return last entry + T pop() { + assert(!empty()); + T l = top(0); + set_size(size()-1); + return l; + } + /// access last entry + T& top(int j=0) { return (*this)[size_-j-1]; } - T last(int j=0) const { + /// return last entry + T top (int j=0) const { return (*this)[size_-j-1]; } + + void swap (int i,int j) { T t((*this)[i]); (*this)[i]=(*this)[j]; @@ -167,6 +173,7 @@ public: destructors. The type T should have a default constructor. It is best suited for simple types, such as int, double or String + It uses stack terminology, (push, pop, top), and can be used as a stack. */ #endif -- 2.39.5