Difference between revisions of "cpp/container/stack"
From cppreference.com
(expand description) |
|||
Line 8: | Line 8: | ||
}} | }} | ||
− | The {{tt|std::stack}} class is a container adapter that gives the programmer the functionality of a stack - specifically, a | + | The {{tt|std::stack}} class is a container adapter that gives the programmer the functionality of a stack - specifically, a FILO (first-in, last-out) data structure. |
+ | |||
+ | The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack. | ||
===Template parameters=== | ===Template parameters=== | ||
− | + | ||
− | + | The underlying container type {{tt|Container}} must implement the following functions: | |
− | {{ | + | |
* {{tt|back()}} | * {{tt|back()}} | ||
Line 19: | Line 20: | ||
* {{tt|pop_back()}} | * {{tt|pop_back()}} | ||
− | The standard containers {{ | + | The standard containers {{tt|std::vector}}, {{tt|std::deque}} and {{tt|std::list}} can be used. |
− | + | ||
===Member types=== | ===Member types=== |
Revision as of 07:08, 23 April 2013
Defined in header <stack>
|
||
template< class T, |
||
The std::stack
class is a container adapter that gives the programmer the functionality of a stack - specifically, a FILO (first-in, last-out) data structure.
The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The stack pushes and pops the element from the back of the underlying container, known as the top of the stack.
Contents |
Template parameters
The underlying container type Container
must implement the following functions:
-
back()
-
push_back()
-
pop_back()
The standard containers std::vector
, std::deque
and std::list
can be used.