📄 lqueue.h
字号:
#ifndef LQUEUE
#define LQUEUE
#include"node.h"
template <class T>
class lQueue
{
private:
node<T> *head,*tail;
public:
lQueue() {head=tail=NULL;}
bool isEmpty()
{
if(head==NULL)
return true;
else
return false;
}
T firstEl()
{
T el=head->info;
return el;
}
T dequeue()
{
T el=head->info;
if(head==tail)
{
tail=NULL;
delete head;
head=NULL;
}
else
{
node<T> *p=head->next;
delete head;
head=p;
}
return el;
}
void enqueue(T el)
{
if(head==NULL)
head=tail=new node<T>(el);
else
{
tail->next=new node<T>(el);
tail=tail->next;
}
}
void clear()
{
node<T> *p=head;
while(head!=NULL)
{
p=head;
head=head->next;
delete p;
}
tail=NULL;
}
int size()
{
int i=0;
for(node<T> *p=head;p!=NULL;p=p->next)
i++;
return i;
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -