Binary Search Tree (C++)
Loading...
Searching...
No Matches
Queue.h
Go to the documentation of this file.
1
19
20#pragma once
21
22#ifndef QUEUE_H
23#define QUEUE_H
24
25#include "Node.h"
26
44
53struct QueueNode {
54 Node* data;
55 QueueNode* next;
56
61 QueueNode(Node* data) : data(data), next(nullptr) {}
62};
63
64class Queue {
65public:
70 Queue() : front(nullptr), rear(nullptr) {}
71
75 ~Queue();
76
81 void enqueue(Node* n);
82
87 Node* dequeue();
88
93 bool isEmpty() const;
94
95private:
96 QueueNode* front;
97 QueueNode* rear;
98};
99
100#endif // QUEUE_H
Declaration of the Node class.
Represents a node within a binary search tree.
Definition Node.h:35
~Queue()
Destroys the Queue.
Definition Queue.cpp:21
Node * dequeue()
Removes and returns the node at the front of the queue.
Definition Queue.cpp:45
void enqueue(Node *n)
Adds a node to the end of the queue.
Definition Queue.cpp:31
bool isEmpty() const
Checks whether the queue is empty.
Definition Queue.cpp:58
Queue()
Constructs an empty queue.
Definition Queue.h:70
Internal node type used by the Queue class.
Definition Queue.h:53
QueueNode(Node *data)
Constructs a QueueNode with the specified node pointer.
Definition Queue.h:61