stack
|
 |
With this adapter, you can use
any container that supports push_back() and pop_back()
as a first-in, last-out data structure.
Library
Standards<ToolKit>
Declaration
#include <stack>
template< class T, class Container >
class stack
Interface
Constructor
explicit
stack()
Constructs an empty
stack.
Constructor
explicit
stack( Container::allocator_type& alloc
)
Constructs an empty stack
using alloc to allocate storage.
Destructor
~stack()
Destroys the stack and
erases all of its items.
=
stack<
Container>& operator=( const stack< Container >& x
)
Replaces the contents of
the stack with the contents of x .
empty
bool
empty() const
Returns true
if the stack contains no elements.
get_allocator
Container::allocator_type
get_allocator() const
Returns a copy of the
allocator the stack is using to manage storage.
pop
void
pop()
Erases the top element in
the stack.
push
void
push( const T& value )
Pushes a copy of value
.
size
size_type
size() const
Returns the number of
elements the stack contains.
top
T&
top()
Returns a reference to
the top element in the stack.
top
const
T& top() const
Returns a reference to
the top element in the stack.
Non-Member Functions
==
bool
operator==( const stack< T, Container >& x
, const stack< T, Container
>& y )
Returns true
if x contains the same items in the same order as y
.
<
bool
operator<( const stack< T, Container >& x
, const stack< T, Container
>& y )
Returns true
if x is lexicographically less than y
.
Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.