Home | Projects | Notes > C++ Programming > Container Adaptor - std::stack

Container Adaptor - std::stack

 

std::stack

Initialization

Because std::stack is a container adaptor, you have the flexibility to specify the underlying container—such as deque, vector, or list—at the time of stack creation.

Stack Operations

For more information, see cppreference.com.

OperationBehavior
push()Insert an element at the top of the stack.
pop()Remove an element from the top of the stack.
top()Access the top element of the stack.
empty()Is the stack empty?
size()Number of elements in the stack.

 

Project: Usage of std::stack

It's best to adhere to the fundamental operations of a stack. Introducing additional methods like insert() compromises the integrity of the stack's intended behavior.