\manpage {b\_stack} {E} {Bounded Stacks}
 
\definition
An instance $S$ of the parameterized data type \name\ is a stack
(see section \ref{Stacks}) of bounded size.
 
\creation S 
 
\create {(int\ n)}
   { creates an instance \var\ of type \name\ that can hold up to $n$
            elements.  \var\ is initialized with the empty stack. }
 
 
\operations 2 4
 
\op  E top {()}
           {  returns the top element of \var.\\
	    \precond $S$ is not empty. }
 
 
\op  E pop {()}
           {  deletes and returns the top element of \var.\\
	  \precond $S$ is not empty. }
 
 
\op  void push {( E\ x)}
           {  adds $x$ as new top element to \var.\\
	 \precond $S$.size() $< n$. }
 
 
\op  void clear {()}
           {  makes \var\ the empty stack. }
 
 
\op  int   size {()}
           {  returns the size of \var. }
 
 
\op  bool   empty {()}
           {  returns true if \var\ is empty, false otherwise. }
 
 
\implementation
Bounded stacks are implemented by \CC vectors. All operations take
time $O(1)$. The space requirement is $O(n)$.
 
