-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPriorityQueue.h
60 lines (49 loc) · 2.04 KB
/
PriorityQueue.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
///////////////////////////////////////////////////////////
// Priority Queue
// Author: Robert T
///////////////////////////////////////////////////////////
#ifndef _DOUBLY_PRIORITYQUEUE
#define _DOUBLY_PRIORITYQUEUE
#include <iostream>
#include <typeinfo>
#include "Node.h"
// definition begin **********************************************************************************
// Interface of PriorityQueue
template <class T>
class PriorityQueue
{
private:
int count = 0; // To track number of entries in the list
int size = 0; // To track the total size of characters
bool sorted = false;
Node<T> *front;
Node<T> *rear;
public:
PriorityQueue(); // Constructor
~PriorityQueue(); // Destructor
// Functions
int getCurrentSize(); // Gets the current number of entries in the list
int getCharSize(); // Gets the total size of characters
bool isEmpty(); // Sees whether the list is empty
void enqueue(T); // Adds a new entry to the list
bool dequeue(T); // Removes one occurrence of a given entry fro m the list
void clear(); // Removes all entries from the list
Node<T> *find(T); // Tests whether the list contains the entry
void moveBefore(Node<T> *, Node<T> *); // Move node before another node
Node<T> *min(); // Get minimum node
void removeMin(); // Remove minimum node
void importDataFile(string); // Import data file
void showList(bool, Node<T> *, int); // Print all nodes
// Sorting
void swap(Node<T> *, Node<T> *);
int bubbleSort();
int selectionSort();
int mergeSort(PriorityQueue<T> &S, int);
void merge(PriorityQueue<T> &S1, PriorityQueue<T> &S2, PriorityQueue<T> &S);
int quickSort(PriorityQueue<T> &S, int);
friend int main();
template <class T>
friend class HuffmanTree;
};
#endif
// definition end **********************************************************************************