# # ifndef QUEUE_H_
# define QUEUE_H_
# include
# include "stack. H"
The template
The class Queue {
Private:
//TODO
The Node
The Node
int length;
Void copy (Node
Void the remove (Node
Public:
The Queue ();
The Queue (Queue & other);
~ the Queue ();
The Queue & operator=(Queue & other);
Const int get_size ();
Void push (T * T);
Void push (Node
The Node
Void the print ();
};
# include "queue. CPP
"# endif
# include "queue. H"
# include
The template
The Queue
{
//TODO
Front back==NULL;
Length=0;
}
The template
The Queue
{
//TODO
If (other. Length==0 | | this==& other)
return;
Length=other. Length;
If (other front==NULL)
{
The front=new Node
}
The else
{
The front=new Node
Copy (this -> front, other front);
}
If (other back==NULL)
{
The back=new Node
}
The else
{
The back=new Node
Copy (this -> back, other back);
}
}
The template
The Queue
{
//TODO
Remove (front);
Remove (back);
}
The template
The Queue
{
//TODO
If (other. Length==0 | | this==& other)
return;
Length=other. Length;
If (other front==NULL)
{
The front=new Node
}
The else
{
The front=new Node
Copy (this -> front, other front);
}
If (other back==NULL)
{
The back=new Node
}
The else
{
The back=new Node
Copy (this -> back, other back);
}
return *this;
}
The template
Int the Queue
{
//TODO
Return length;
}
The template
Void Queue
{
//TODO
If (t==NULL)
return;
If (length==0)
{
Front back==new Node
The back -> set_next (NULL);
Length++;
return;
}
The else
{
The back -> set_next (new Node
The back=back -> get_next ();
The back -> set_next (NULL);
Length++;
return;
}
}
The template
Void Queue
{
//TODO
If (n==NULL)
return;
If (length==0)
{
The front=back=n;
The back -> set_next (NULL);
Length++;
return;
}
The else
{
The back -> set_next (n);
The back=back -> get_next ();
The back -> set_next (NULL);
Length++;
return;
}
}
The template
The Queue Node
{
//TODO
If (length==0)
Return NULL;
Else if (length==1)
{
The Node
Front back==NULL;
length--;
Return h;
}
The else
{
The Node
The front=front -> get_next ();
length--;
Return h;
}
}
The template
Void Queue
{
//TODO
Stack
The Node
The Node
While (length!=0)
{
N=this -> pop ();
S -> push (n);
}
While (s -> get_size ()!=0)
{
T=s -> pop ();
T -> print ();
}
STD: : cout <"END"
}
The template
Void Queue
{
If (other_ -> get_next ()==NULL)
{
return;
}
This_ -> set_next (new Node
Copy (this_ -> get_next (), other_ -> get_next ());
return;
}
The template
Void Queue
{
If (n==NULL)
{
return;
}
If (n -> get_next ()==NULL)
{
The delete n;
return;
}
The Node
The delete n;
Remove (TMP);
return;
}