当前位置:网站首页>Chapter XI queue of STL
Chapter XI queue of STL
2022-07-19 09:32:00 【qq_ forty-three million two hundred and five thousand two hundr】
1 queue Basic concepts

2 queue Common interfaces
#include <queue>
#include <string>
class Person
{
public:
Person(string name, int age)
{
this->m_Name = name;
this->m_Age = age;
}
string m_Name; int m_Age;
};
void test01()
{
// Create a queue
queue<Person> q;
// Prepare the data
Person p1(" Tang's monk ", 30);
Person p2(" The Monkey King ", 1000);
Person p3(" Pig eight quit ", 900);
Person p4(" Monk sha ", 800);
// Add elements to the queue Joining operation
q.push(p1);
q.push(p2);
q.push(p3);
q.push(p4);
// The queue does not provide an iterator , Random access is not supported
while (!q.empty())
{
// Output team head element
cout << " Team leader element -- full name : " << q.front().m_Name << " Age : "<< q.front().m_Age << endl;
cout << " Team tail element -- full name : " << q.back().m_Name << " Age : " << q.back().m_Age << endl;
cout << endl;
// Pop team leader element
q.pop();
}
cout << " The queue size is :" << q.size() << endl;
}
int main()
{
test01();
return 0;
}Output results :
Team leader element -- full name : Tang's monk Age : 30
Team tail element -- full name : Monk sha Age : 800
Team leader element -- full name : The Monkey King Age : 1000
Team tail element -- full name : Monk sha Age : 800
Team leader element -- full name : Pig eight quit Age : 900
Team tail element -- full name : Monk sha Age : 800
Team leader element -- full name : Monk sha Age : 800
Team tail element -- full name : Monk sha Age : 800
The queue size is :0边栏推荐
- mysql进阶(六)模糊查询的四种常见用法介绍
- cookie和session在实际项目中的使用
- 【ACWing】947. 文本编辑器
- Etcd database source code analysis -- etcdserver bootstrap recover store from snapshot
- 【论文笔记】基于深度学习的视觉检测及抓取方法
- MySql数据是如何存储在磁盘上存储的?
- SharePoint access brief notes
- 【C语言】自定义类型初阶知识点
- Etcd database source code analysis - initialize etcdserver structure
- 力扣(LeetCode)197. 上升的温度(2022.07.16)
猜你喜欢

在Pycharm里面如何避免全局索引?如何取消对于某个文件夹的索引?

OLED显示如何理解 12*6、16*8、24*12等字符大小

Componentized advanced -- slot

el-table 列拖拽(无须引入其他插件)

C51 常见数据类型详解

将视频格式转换为gif图片格式

第一部分—C语言基础篇_2. 数据类型

OLED displays how to understand the character sizes of 12*6, 16*8, 24*12, etc

Flink小知识--任务调度slot的配置 slotSharingGroup

DuiLib 实现tooltip自定义鼠标提示窗口
随机推荐
[troubleshooting] common problems and solutions when installing MySQL in Windows system
v-mode
将视频格式转换为gif图片格式
MySQL view
如何正确执行Jedis单元测试
目标检测模型大小计算,模型复杂度(参数换算公式)
[performance optimization methodology series] VI. summary
Interview questions - design test cases for:: memcpy function
R语言ggplot2可视化分面图(faceting):ggplot2可视化分面图并移除分面图之间的边框线、以及分面图之间的间隙(Remove Spacing between Panels)
电脑拨号上网
es概念模型与基本故障
Es conceptual model and basic faults
mysql进阶(六)模糊查询的四种常见用法介绍
Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS) (found suitable exact version “11.4“)
Line Flow Based Simultaneous Localization and Mapping
开发第一个Flink应用
【C语言】浮点型在内存的存储
Line Flow Based Simultaneous Localization and Mapping
Makefile中在命令前加上- 则忽略该命令产生的错误,继续执行下一条命令
LDA classifier