数据结构---队列

来源:互联网 发布:程序员薪资调查报告 编辑:程序博客网 时间:2024/06/05 11:34

1、队列是一种“先进先出”的结构(FIFO)。可分为:普通队列和环形队列。

环形队列:

下面程序是环形队列实现的过程:

头文件:

#pragma oncea
#ifndef MYQUEUE_H
#define MYQUEUE_H
class MyQueue
{
public:
MyQueue(int queueCapacity);
virtual ~MyQueue();
void ClearQueue();//清空队列
bool QueueEmpty() const; //判空队列
int QueueLength() const;//队列长度
bool EnQueue(int element);//新元素入队
bool  DeQueue(int &element);//首元素出对
void QueueTraverse();//遍历队列
bool QueueFull(); //判断队列是否满
private:
int *m_pQueue; //队列数组指针
int m_iQueueLen; //队列元素个数
int m_iQueueCapacity;//队列元素容量
int m_iHead;
int m_iTrail;
};


#endif // !1
2、C++STL标准库中队列的运用

http://www.cppblog.com/zhenglinbo/archive/2012/09/18/191170.html

0 0
原创粉丝点击