C + +, stacks and queues

Source: Internet
Author: User

1, header file

#include <stack>

#include <queue>

2, statement

Stack<int> stacktest;

Queue<int> queuetest;

3, Common function operation

(1) Stack

S.empty () returns               true if the stack is empty, otherwise returns Falses.size () returns the                number of elements in the stack s.pop ()                 removes the top element of the stack without returning its value s.top ()                 returns the element at the top of the stack, But does not delete the element S.push () pushes                a new element at the top of the stack

(2) Queue

Q.empty () returns               true if the queue is empty, otherwise returns Falseq.size () returns the                number of elements in the queue Q.pop ()                 deletes the first element of the queue but does not return its value Q.front ()               returns the value of the first element of the team, But do not delete the element Q.push ()                at the end of the team press into the new element Q.back ()                returns the value of the tail element of the queue, but does not delete the element

C + +, stacks and queues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.