博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
stl:queue 源码_C ++ STL中的queue :: front()和queue :: back()
阅读量:2531 次
发布时间:2019-05-11

本文共 1639 字,大约阅读时间需要 5 分钟。

stl:queue 源码

In C++ STL, Queue is a type of container that follows FIFO (First-in-First-Out) elements arrangement i.e. the elements which insert first will be removed first. In queue, elements are inserted at one end known as "back" and are deleted from another end known as "front".

在C ++ STL中,队列是遵循FIFO(先进先出)元素排列的一种容器,即,首先插入的元素将被首先删除。 在队列中,元素被插入称为“ back”的一端,并从称为“ front”的另一端删除。

1)C ++ STL queue :: front()函数 (1) C++ STL queue::front() function)

The function front() returns the reference to the first element in the queue i.e. the oldest element in the queue, so it is used to get the first element from the front of the list of a queue.

函数front()返回对队列中第一个元素(即队列中最旧的元素)的引用,因此它用于从队列列表的开头获取第一个元素。

Syntax:

句法:

queue_name.front();

2)C ++ STL queue :: back()函数 (2) C++ STL queue::back() function)

The function back() returns the reference to the last element in the queue i.e. the newest element in the queue, so it is used to get the first element from the back of the list of a queue.

函数back()返回对队列中最后一个元素(即队列中的最新元素)的引用,因此它用于从队列列表的后面获取第一个元素。

Syntax:

句法:

queue_name.back();

Program:

程序:

// cpp program for queue implementation // Example of front() and back()#include 
#include
using namespace std;//Main functionint main() {
// declaring an empty queue queue
Q; //inserting elements Q.push(10); Q.push(20); Q.push(30); Q.push(40); Q.push(50); cout<<"First element of the queue: "<
<

Output

输出量

First element of the queue: 10 Last element of the queue : 50 After removing two elements... First element of the queue: 30 Last element of the queue : 50

翻译自:

stl:queue 源码

转载地址:http://nwozd.baihongyu.com/

你可能感兴趣的文章
小D课堂 - 新版本微服务springcloud+Docker教程_5-01分布式核心知识之熔断、降级
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-04 feign结合hystrix断路器开发实战下...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-03 feign结合hystrix断路器开发实战上...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-01 微服务网关介绍和使用场景
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-05熔断降级服务异常报警通知
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-03 高级篇幅之zuul常用问题分析
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-08 断路器监控仪表参数
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-02 springcloud网关组件zuul
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-1.快速搭建SpringBoot项目,采用Eclipse...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_1-4.在线教育后台数据库设计...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-3.热部署在Eclipse和IDE里面的使用...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_1-3.在线教育站点需求分析和架构设计...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-4.后端项目分层分包及资源文件处理...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-2.快速搭建SpringBoot项目,采用IDEA...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_3-5.PageHelper分页插件使用
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-6.微信扫码登录回调本地域名映射工具Ngrock...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-8.用户模块开发之保存微信用户信息...
查看>>
Linux下Nginx安装
查看>>
LVM扩容之xfs文件系统
查看>>
Hbase记录-client访问zookeeper大量断开以及参数调优分析(转载)
查看>>