Version: 3.0.2
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.
 
typedef container_type::size_type size_type
 Type returned by size() method.
 
typedef container_type::value_type value_type
 Type of the elements stored in the stack.
 

Public Member Functions

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

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.