#include
using namespace std;
typedef int T;
class qNode
{
public:
T data;
qNode* next = NULL;
};
class queue
{
private:
qNode* head;
qNode* rear;
int capacity;
public:
queue(int length = 0);
~queue();
int size()const;
void inQueue(T a);
T outQueue();
void printWholely()const;
int find(T a)const;
};
queue::queue(int length)
{
head = new qNode;
rear = new qNode;
qNode* temp = head;
while(length--)
{
temp->next = new qNode;
temp = temp->next;
cin>>temp->data;
capacity++;
}
temp->next = rear;
}
queue::~queue()
{
qNode* temp = head->next;
while(head->next != NULL)
{
qNode* temp = head->next;
delete head;
head = temp;
}
delete head;
}
int queue::size()const
{
return capacity;
}
void queue::inQueue(T a)
{
rear->data = a;
rear->next = new qNode;
rear = rear->next;
capacity++;
}
T queue::outQueue()
{
qNode* temp = head->next;
head->next = head->next->next;
delete temp;
capacity--;
}
void queue::printWholely()const
{
qNode* temp = head->next;
if(capacity == 0)cout<<"it is a empty queue!";
while(temp != rear)
{
cout<data<next;
}
}
int queue::find(T a)const
{
qNode* temp = head->next;
int index = 0;
while(temp != rear)
{
if(temp->data == a)return index;
temp = temp->next;
index++;
}
return -1;
}
int main()
{
return 0;
}