#include<string>
#include<assert.h>
#include<iostream>
typedef int status;
#define OK 1
#define ERROR 0
template<class type>
class order_tream
{

public:
order_tream(int a):size(a+1),n(0)
{
base =new type [a+1];
assert(base!=0);
front=0;
rear=0;
}
int n;
status full();//判断是否为满
status empty();//判断是否为空
void putin(int a);//输入
status enqueue(type a);//进队列
status sqqueue(type &a);//出队列
void clear();//清空
status out();//输出整个队列
private:
int rear;//尾
int front;//头
int size;
type* base;
};
/*进队列*/
template<class type>
status order_tream<type>::enqueue(type a)
{
if( full())
return ERROR;
base[rear]=a;
rear=(rear+1)%size;
n++;
return OK;
}
/*清空*/
template<class type>
void order_tream<type>::clear()
{
front=rear;
}
/*输入*/
template<class type>
void order_tream<type>::putin(int a)
{
type x;
cout<<"输入开始"<<endl;
for(int i=0;i<a;i++)
{
cin>>x;
enqueue(x);
}
}
/*出队列*/
template<class type>
status order_tream<type>::sqqueue(type& a)
{
if(empty())
return ERROR;
a=base[front];
front=(front+1)%size;
n--;
return OK;
}
/*判断是否为空*/
template<class type>
status order_tream<type>::empty()
{
if(front==rear)
return OK;
else
return ERROR;
}
/*判断是否为满*/
template<class type>
status order_tream<type>::full()
{
if(front==rear+1)
return OK;
else
return ERROR;
}
/*输出整个队列*/
template<class type>
status order_tream<type>::out()
{
if(empty())
return ERROR;
type a;
for(int i=0;i<n;i++)
{
a=base[i];
cout<<a<<'\t';
}
cout<<n;
cout<<endl;
return OK;
}

c++队列基本功能的更多相关文章

  1. 【springboot】【redis】springboot+redis实现发布订阅功能,实现redis的消息队列的功能

    springboot+redis实现发布订阅功能,实现redis的消息队列的功能 参考:https://www.cnblogs.com/cx987514451/p/9529611.html 思考一个问 ...

  2. redis 的消息订阅和消息队列的功能比较

    消息队列常用的有 rabitMQ.kafka等.缓存服务器  redis 也可以做消息队列使用,他们的特点对比如下 消息协议: 消息队列支持包括AMQP,MQTT,Stomp等,并且支持 JMS 规范 ...

  3. LinkedList(实现了queue,deque接口,List接口)实现栈和队列的功能

    LinkedList是用双向链表结构存储数据的,很适合数据的动态插入和删除,随机访问和遍历速度比较慢. 底层是一个双向链表,链表擅长插入和删除操作,队列和栈最常用的2种操作都设计到插入和删除 impo ...

  4. 网络损伤仪WANsim的队列深度功能

    什么是队列深度 在网络损伤仪WANsim中,队列是指一个用于缓存报文的缓冲池.深度是指缓冲池可以存储的最大数据量.当WANsim接受的报文超出了带宽限制的量时,溢出的报文会进入队列中. 我们可以在WA ...

  5. C#实现rabbitmq 延迟队列功能

    最近在研究rabbitmq,项目中有这样一个场景:在用户要支付订单的时候,如果超过30分钟未支付,会把订单关掉.当然我们可以做一个定时任务,每个一段时间来扫描未支付的订单,如果该订单超过支付时间就关闭 ...

  6. oracle 队列

    Oracle 高级队列(AQ) 适用对象:初步了解oracle高级队列人群 注意事项: 序号 注意事项 1 JMS监听部分可参考官方文档: http://docs.oracle.com/cd/e128 ...

  7. rabbitmq批量删除队列

    有些时候,我们需要批量的删除rabbitmq中的队列,尤其是对于那些客户端配置了队列不存在时自动创建,但断开时不自动删除的应用来说. rabbitmqctl并没有包含直接管理队列的功能,其提供的vho ...

  8. Java多线程与并发库高级应用-可阻塞的队列

    ArrayBlockQueue 可阻塞的队列 > 队列包含固定长度的队列和不固定长度的队列. > ArrayBlockQueue > 看BlockingQueue类的帮助文档,其中有 ...

  9. PHP的轻量消息队列php-resque使用说明

    日志未经声明,均为AlloVince原创.版权采用『 知识共享署名-非商业性使用 2.5 许可协议』进行许可. 消息队列处理后台任务带来的问题 项目中经常会有后台运行任务的需求,比如发送邮件时,因为要 ...

随机推荐

  1. python 补漏计划

    从今天开始把python的细枝末节都梳理下 争取 每星期 两篇博文

  2. poj3581

    Sequence Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6893   Accepted: 1534 Case Tim ...

  3. JavaScript零基础学习系列五

    定时器 1.定时器:设定时间,在指定的时间之后执行函数或者是程序   a.反复性定时器:var dingshiqi=Window.setInterval("函数名()",时间n[毫 ...

  4. react 表单

    import React ,{PropTypes}from 'react'; import { render } from 'react-dom'; const styles={ mb10:{ mar ...

  5. Oracle视图时间戳转为Date

    CREATE OR REPLACE VIEW PDAORDER AS SELECT po.id id, po.order_no AS order_no, po.money AS money, (SEL ...

  6. 【Codeforces235C】Cyclical Quest 后缀自动机

    C. Cyclical Quest time limit per test:3 seconds memory limit per test:512 megabytes input:standard i ...

  7. Python 【第九章】 Django基础

    在windows 命令行上安装Django 在CMD命令行中输入以下命令进行安装. pip install Django 在windows python安装目录上会出现 一个django-admin. ...

  8. Python 【第七章】:Html 和 CSS

    HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都来遵守他,这样就可以让浏览器根据标 ...

  9. php 远程本地化无后缀图片

    $body = '<p style="margin: 0px 0px 1.1em; padding: 0px; color: rgb(51, 51, 51); font-family: ...

  10. Neural Network Toolbox使用笔记1:数据拟合

    http://blog.csdn.net/ljp1919/article/details/42556261 Neural Network Toolbox为各种复杂的非线性系统的建模提供多种函数和应用程 ...