-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortAlgo.hpp
More file actions
86 lines (52 loc) · 2.33 KB
/
SortAlgo.hpp
File metadata and controls
86 lines (52 loc) · 2.33 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// Created by User on 25.06.2023.
//
#ifndef UNTITLED_SORTALGO_HPP
#define UNTITLED_SORTALGO_HPP
#include "Engine.hpp"
#include "HUD.hpp"
using namespace std::literals::chrono_literals;
class SortAlgo {
public:
SortAlgo();
~SortAlgo();
public:
//std::unique_ptr<HUD> hud;
HUD * hud;
private:
//CLOCKS
sf::Clock sortTime;
private:
//VIEWS
sf::View mainView;
public:
void bubbleSort(std::vector<int> &array, sf::RenderWindow &renderWindow);
void selectionSort(std::vector<int> &array, sf::RenderWindow &renderWindow);
void insertionSort(std::vector<int> &array, sf::RenderWindow &renderWindow);
void merge(std::vector<int> &arr, int left, int mid, int right);
void mergeSort(std::vector<int> &arr, int left, int right, sf::RenderWindow &renderWindow);
int partition(std::vector<int> &arr, int low, int high, sf::RenderWindow &renderWindow);
void quickSort(std::vector<int> &arr, int low, int high, sf::RenderWindow &renderWindow);
void heapify(std::vector<int> &arr, int n, int i, sf::RenderWindow &renderWindow);
void heapSort(std::vector<int> &arr, sf::RenderWindow &renderWindow);
// Counting sort for a specific digit (exp)
void countingSort(std::vector<int> &arr, int exp, sf::RenderWindow &renderWindow);
void radixSort(std::vector<int> &arr, sf::RenderWindow &renderWindow);
void bucketSort(std::vector<int> &arr, int numBuckets, sf::RenderWindow &renderWindow);
void shellSort(std::vector<int> &arr, sf::RenderWindow &renderWindow);
void bingoSort(std::vector<int> &vec, sf::RenderWindow &renderWindow);
void combSort(std::vector<int> &arr, sf::RenderWindow &renderWindow);
void pigeonholeSort(std::vector<int> &arr, sf::RenderWindow &renderWindow) const;
void cycleSort(std::vector<int> &arr, sf::RenderWindow &renderWindow);
private:
//Utility
// Get the maximum value in the array
int getMax(const std::vector<int> &arr);
/* Function for finding the maximum and minimum element of
the Array */
void maxMin(std::vector<int> vec, int n, int &bingo, int &nextBingo);
bool checkIfSorted(const std::vector<int> &array);
void drawArray(const std::vector<int> &array, sf::RenderWindow &renderWindow, unsigned short redPos,
unsigned short greenPos) const;
};
#endif //UNTITLED_SORTALGO_HPP