循环链表
#include <assert.h>
template<class T>
class Queue
{
public:
Queue(int =10);
~Queue(delete []element;)
void EnQueue(T item);
T DeQueue();
T GetFront();
void MakeEmpty()
{length =0;}
int IsEmpty(){reutrn length ==0;}
int IsFull()const{return length == Maxsize; }
private:
//队列的成员
int rear,lenght;
T *element;
int Maxsize;
} ;
template<class T>
Queue<T>::Queueu(int n):rear(Maxsize-1),length(0),Maxsie(n)
{ //创建一片连续的空间
element = new T[Maxsize];
assert(element);
}
template<class T>
Queue<T::>void EnQueue(T &item)
{
if(IsFull())
printf("full\n");
retrun;
length ++;
rear = (rear+1)%Maxsize;
element[rear] = item;
}
template<class T>
T Queue<T>::Queue DeQueue()
{
assert(IfEmpty());
lenth--;
return element[(rear-length+Maxsize)% maxsize];
template<class T>
T Queue<T>::GetFront()
{
assert(!Isempty());
return element[(rear-length+Maxsize)%Maxsize]; //返回队头
}
}