#include <itpp/base/stack.h>
Public Member Functions | |
Stack () | |
Default constructor. | |
Stack (int n) | |
Create a Stack of size n . | |
Stack (const Stack< T > &s) | |
Create a copy of s . | |
virtual | ~Stack () |
Default destructor. | |
T | pop () |
Pop the topmost element of the stack. | |
T | peek () const |
Peek at the topmost element of the stack, without removing it. | |
void | push (T v) |
Push an element at top of stack. | |
void | clear () |
Empty the stack. | |
void | operator= (const Stack< T > &s) |
Assignment operator. | |
int | size () const |
Returns the maximum number of data elements the stack can store. | |
int | no_elements () const |
Returns the number of data elements currently in the stack. | |
void | set_size (int n, bool copy=false) |
Resizing a Stack<T>. |
This class is a general stack class for arbitrary types.
For rarely used types you will need to instantiate the class by
template class Stack<type>;
The following example shows how to define a Stack of vectors:
vec a = randn(10); vec b = randn(20); Stack<vec> my_stack(10); my_stack.push(a); my_stack.push(b); cout << my_stack.pop() << " " << my_stack.pop() << endl ;
Definition at line 69 of file stack.h.
itpp::Stack< T >::Stack | ( | ) | [inline] |
itpp::Stack< T >::Stack | ( | int | n | ) | [inline] |
itpp::Stack< T >::Stack | ( | const Stack< T > & | s | ) | [inline] |
Create a copy of s
.
Definition at line 127 of file stack.h.
References itpp::Stack< T >::data, itpp::Stack< T >::ndata, and itpp::Stack< T >::valptr.
itpp::Stack< T >::~Stack | ( | ) | [inline, virtual] |
T itpp::Stack< T >::pop | ( | ) | [inline] |
Pop the topmost element of the stack.
Definition at line 144 of file stack.h.
References it_error_if.
T itpp::Stack< T >::peek | ( | ) | const [inline] |
Peek at the topmost element of the stack, without removing it.
Definition at line 152 of file stack.h.
References it_error_if.
void itpp::Stack< T >::push | ( | T | v | ) | [inline] |
void itpp::Stack< T >::clear | ( | ) | [inline] |
void itpp::Stack< T >::operator= | ( | const Stack< T > & | s | ) | [inline] |
Assignment operator.
Definition at line 197 of file stack.h.
References itpp::Stack< T >::data, itpp::Stack< T >::ndata, and itpp::Stack< T >::set_size().
int itpp::Stack< T >::size | ( | ) | const [inline] |
int itpp::Stack< T >::no_elements | ( | ) | const [inline] |
void itpp::Stack< T >::set_size | ( | int | n, | |
bool | copy = false | |||
) | [inline] |
Resizing a Stack<T>.
Definition at line 206 of file stack.h.
References itpp::min().
Referenced by itpp::Stack< T >::operator=().
Generated on Wed Apr 18 11:45:38 2007 for IT++ by Doxygen 1.5.2