Go: Stack and queue trivia "STL usage"

Source: Internet
Author: User

Original source: http://blog.csdn.net/chenzhenyu123456/article/details/44519943

Stack:

(a) header file #include <stack>

(ii) Definition of stack stack<int>s;

(iii) Use

1:s.empty () stack is null returns TRUE, otherwise returns false;

2:s.size () returns the number of elements in the stack

3:s.pop () removes the top element of the stack without returning its value

4:s.top () returns the element at the top of the stack without deleting the element

5:s.push () pushes a new element at the top of the stack

Queue:

(a) header file #include <queue>

(ii) Definition of queue<int>q;

(iii) Use

1:q.empty () returns True if the queue is empty , otherwise false;

2:q.size () returns the number of elements in the queue

3:q.pop () deletes the first element of the queue but does not return its value

4:q.front () Returns the value of the first element of the team, but does not delete the element

5:q.push () Press the new element at the end of the team

6:q.back () Returns the value of the tail element of the queue, but does not delete the element

Go: Stack and queue trivia "STL usage"

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.