91 int size()
const {
return ndata; }
95 void set_size(
int n,
bool copy =
false);
131 for (
int i = 0; i < s.ndata; i++)
144 it_error_if(valptr == 0,
"Stack<T>::pop: Empty stack");
152 it_error_if(valptr == 0,
"Stack<T>::peek: Empty stack");
153 return data[valptr-1];
159 it_error_if(valptr >= ndata,
"Stack<T>::push: Full stack");
198 for (
int i = 0; i < ndata; i++)
214 min = ndata < sz ? ndata : sz;
216 for (i = 0; i <
min; i++)
229 #endif // #ifndef STACK_H #define it_error_if(t, s)
Abort if t is true.
void push(T v)
Push an element at top of stack.
void set_size(int n, bool copy=false)
Resizing a Stack<T>.
void clear()
Empty the stack.
T pop()
Pop the topmost element of the stack.
int size() const
Returns the maximum number of data elements the stack can store.
T peek() const
Peek at the topmost element of the stack, without removing it.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
T min(const Vec< T > &in)
Minimum value of vector.
virtual ~Stack()
Default destructor.
Stack()
Default constructor.
Error handling functions - header file.
void operator=(const Stack< T > &s)
Assignment operator.
int no_elements() const
Returns the number of data elements currently in the stack.