C + + standard library function stacks and queues

Source: Internet
Author: User

When using the stack and queue of a standard library, you should include the first-minute files.
The header file should be included in the stack: #include < stack >
Definition: stack< int > S;

s.empty();         //如果栈为空则返回true, 否则返回false;s.size();          //返回栈中元素的个数s.top();           //返回栈顶元素, 但不删除该元素s.pop(); //弹出栈顶元素, 但不返回其值s.push(); //将元素压入栈顶

Include header files: #include < queue >
Definition: queue< int > q;

q.empty();         //如果队列为空返回true, 否则返回false     q.size();          //返回队列中元素的个数q.front();         //返回队首元素但不删除该元素q.pop(); //弹出队首元素但不返回其值q.push(); //将元素压入队列q.back(); //返回队尾元素的值但不删除该元素

C + + standard library function 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.