博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C ++ STL中的queue :: push()和queue :: pop()
阅读量:2528 次
发布时间:2019-05-11

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

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”的另一端删除。

Note: In the , "push" is an operation to insert an element in any container, "pop" is an operation to remove an element from the container.

注意:在 , “ push”是在任何容器中插入元素的操作, “ pop”是从容器中删除元素的操作。

1)C ++ STL队列:: push()函数 (1) C++ STL queue::push()function)

push() inserts an element to queue at the back. After executing this function, element inserted in the queue and its size increased by 1.

push()在后面插入一个要排队的元素。 执行此功能后,插入队列中的元素及其大小增加了1。

Syntax:

句法:

queue_name.push(element);

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

pop() removes an element from the front of the queue. After executing this function, the oldest element removed from the queue and its size decreased by 1.

pop()从队列的开头删除一个元素。 执行此功能后,最旧的元素从队列中删除,其大小减小了1。

Syntax:

句法:

queue_name.pop();

Program:

程序:

// cpp program for queue implementation // Example of push() and pop()#include 
#include
using namespace std;//function to print the queue void printQueue(queue
q){
// printing content of queue while (!q.empty()) {
cout<<" "<
Q; //inserting elements Q.push(10); Q.push(20); Q.push(30); Q.push(40); Q.push(50); cout<<"Queue elements after inserting elements:"<

Output

输出量

Queue elements after inserting elements:  10 20 30 40 50Queue elements after removing elements: 30 40 50

翻译自:

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

你可能感兴趣的文章
阶段3 2.Spring_04.Spring的常用注解_3 用于创建的Component注解
查看>>
阶段3 2.Spring_04.Spring的常用注解_2 常用IOC注解按照作用分类
查看>>
阶段3 2.Spring_09.JdbcTemplate的基本使用_5 JdbcTemplate在spring的ioc中使用
查看>>
阶段3 3.SpringMVC·_07.SSM整合案例_02.ssm整合之搭建环境
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第1节零基础快速入门SpringBoot2.0_3、快速创建SpringBoot应用之手工创建web应用...
查看>>
阶段3 3.SpringMVC·_07.SSM整合案例_04.ssm整合之编写SpringMVC框架
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第1节零基础快速入门SpringBoot2.0_5、SpringBoot2.x的依赖默认Maven版本...
查看>>
阶段3 3.SpringMVC·_07.SSM整合案例_08.ssm整合之Spring整合MyBatis框架
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第2节 SpringBoot接口Http协议开发实战_9、SpringBoot基础HTTP其他提交方法请求实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第2节 SpringBoot接口Http协议开发实战_12、SpringBoot2.x文件上传实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第4节 Springboot2.0单元测试进阶实战和自定义异常处理_19、SpringBoot个性化启动banner设置debug日志...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第4节 Springboot2.0单元测试进阶实战和自定义异常处理_20、SpringBoot2.x配置全局异常实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第5节 SpringBoot部署war项目到tomcat9和启动原理讲解_23、SpringBoot2.x启动原理概述...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第4节 Springboot2.0单元测试进阶实战和自定义异常处理_21、SpringBoot2.x配置全局异常返回自定义页面...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第8节 数据库操作之整合Mybaties和事务讲解_32..SpringBoot2.x持久化数据方式介绍...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第8节 数据库操作之整合Mybaties和事务讲解_34、SpringBoot整合Mybatis实操和打印SQL语句...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第8节 数据库操作之整合Mybaties和事务讲解_35、事务介绍和常见的隔离级别,传播行为...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_40、Redis工具类封装讲解和实战...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_37、分布式缓存Redis介绍...
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第10节 SpringBoot整合定时任务和异步任务处理_42、SpringBoot常用定时任务配置实战...
查看>>