-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFIFOQueueClass.h
More file actions
41 lines (38 loc) · 1.61 KB
/
FIFOQueueClass.h
File metadata and controls
41 lines (38 loc) · 1.61 KB
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
#ifndef _FIFOQUEUECLASS_H_
#define _FIFOQUEUECLASS_H_
#include "LinkedNodeClass.h"
// This class will be used to store a simple
// first-in-first-out queue data structure.
template < class T >
class FIFOQueueClass
{
private:
LinkedNodeClass< T > *head; //Points to the first node in a queue, or NULL
//if queue is empty.
LinkedNodeClass< T > *tail; //Points to the last node in a queue, or NULL
//if queue is empty.
public:
//Default Constructor. Will properly initialize a queue to
//be an empty queue, to which values can be added.
FIFOQueueClass();
//Inserts the value provided (newItem) into the queue.
void enqueue(const T &newItem);
//Attempts to take the next item out of the queue. If the
//queue is empty, the function returns false and the state
//of the reference parameter (outItem) is undefined. If the
//queue is not empty, the function returns true and outItem
//becomes a copy of the next item in the queue, which is
//removed from the data structure.
bool dequeue(T &outItem);
//Prints out the contents of the queue. All printing is done
//on one line, using a single space to separate values, and a
//single newline character is printed at the end.
void print() const;
//Destructor, which will free up all dynamic memory associated
//with this queue when the list is destroyed (i.e when a statically
//allocated queue goes out of scope or a dynamically allocated queue
//is deleted).
~FIFOQueueClass();
};
#include "FIFOQueueClass.inl"
#endif