queue.h
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| class Element {
public:
char Command;
char CharToSend;
Element *NextCommand;
Element (char CommandToSend,char Char);
};
class Queue {
public:
Queue();
Element *First;
Element *Last;
void AddToQueue(char Command,char Char);
void DeleteFirstQueue();
void DeleteAllQueue();
}; |
|
queue.cpp
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| Element::Element (char CommandToSend,char Char){
Command=CommandToSend;
CharToSend=Char;
NextCommand=NULL;
};
Queue::Queue(){
First=NULL;
Last=NULL;
};
void Queue::AddToQueue(char Command,char Char){
if (First==NULL){
First = new Element(Command,Char);
Last = First;
}
else
{
Last->NextCommand = new Element(Command,Char);
Last=Last->NextCommand;
}
};
void Queue::DeleteFirstQueue()
{
Element *Pointer;
if(First!=NULL)
{
Pointer=First->NextCommand;
delete First;
First=Pointer;
}
else
Last=NULL;
};
void Queue::DeleteAllQueue()
{
while(First!=NULL)
DeleteFirstQueue();
}; |
|
|