C++ STL: Stack

C++ STL: Stack

Stacks are specifically designed to operate in a LIFO context (Last In First Out), where elements can only be inserted from the top and accessed from the top.

Image stack like a stack of plates, to access a plate placed at the bottom you need to remove all top plates first.

Here are some member functions of the STL stack class:

Member functions of C++ stack

  • empty: tests whether a stack is empty or not.
  • size: return the size
  • top: return the element at the top of the stack
  • push: Insert the element at the top of the stack
  • emplace: Create an insert an element at the top of the stack.
  • pop: Remove the top element
  • Swap: swap the contents of two stacks.

Here is the official documentation for the c++ stack: http://www.cplusplus.com/reference/stack/stack/

No comments:

Post a Comment

Installing albert on ubuntu 19.04

Installing Albert on Ubuntu 19.04... Albert is not still released for ubuntu 19.04. But still, you can install it using the following ...