Version: 3.0.4
wxStack< T > Class Template Reference

#include <wx/stack.h>

Detailed Description

template<typename T>
class wxStack< T >

wxStack<T> is similar to std::stack and can be used exactly like it.

If wxWidgets is compiled in STL mode, wxStack will just be a typedef to std::stack but the advantage of this class is that it is also available on the (rare) platforms where STL is not, so using it makes the code marginally more portable. If you only target the standard desktop platforms, please always use std::stack directly instead.

The main difference of this class compared to the standard version is that it always uses wxVector<T> as the underlying container and doesn't allow specifying an alternative container type. Another missing part is that the comparison operators between wxStacks are not currently implemented. Other than that, this class is exactly the same as std::stack, so please refer to the STL documentation for further information.

Library:  None; this class implementation is entirely header-based.
Category:  Containers
See also
Container Classes, wxVector<T>
Since
2.9.2

Public Types

typedef wxVector< T > container_type
 Type of the underlying container used. More...
 
typedef container_type::size_type size_type
 Type returned by size() method. More...
 
typedef container_type::value_type value_type
 Type of the elements stored in the stack. More...
 

Public Member Functions

bool empty () const
 Return whether the stack is currently empty. More...
 
size_type size () const
 Return the number of elements in the stack. More...
 
void push (const value_type &val)
 Adds an element to the stack. More...
 
void pop ()
 Removes the element currently on top of the stack. More...
 
 wxStack ()
 Stack can be created either empty or initialized with the contents of an existing compatible container. More...
 
 wxStack (const container_type &cont)
 Stack can be created either empty or initialized with the contents of an existing compatible container. More...
 
value_typetop ()
 Return the element on top of the stack. More...
 
const value_typetop ()
 Return the element on top of the stack. More...
 

Member Typedef Documentation

template<typename T >
typedef wxVector<T> wxStack< T >::container_type

Type of the underlying container used.

template<typename T >
typedef container_type::size_type wxStack< T >::size_type

Type returned by size() method.

template<typename T >
typedef container_type::value_type wxStack< T >::value_type

Type of the elements stored in the stack.

Constructor & Destructor Documentation

template<typename T >
wxStack< T >::wxStack ( )

Stack can be created either empty or initialized with the contents of an existing compatible container.

template<typename T >
wxStack< T >::wxStack ( const container_type cont)
explicit

Stack can be created either empty or initialized with the contents of an existing compatible container.

Member Function Documentation

template<typename T >
bool wxStack< T >::empty ( ) const

Return whether the stack is currently empty.

template<typename T >
void wxStack< T >::pop ( )

Removes the element currently on top of the stack.

template<typename T >
void wxStack< T >::push ( const value_type val)

Adds an element to the stack.

template<typename T >
size_type wxStack< T >::size ( ) const

Return the number of elements in the stack.

template<typename T >
value_type& wxStack< T >::top ( )

Return the element on top of the stack.

template<typename T >
const value_type& wxStack< T >::top ( )

Return the element on top of the stack.