-
Notifications
You must be signed in to change notification settings - Fork 1
/
sorts.hpp
33 lines (28 loc) · 1.05 KB
/
sorts.hpp
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
#pragma once
#include <functional>
#include <map>
#include <string>
template <typename T>
using callback_type = std::function<void(typename T::value_type,
typename T::value_type)>;
template <typename T>
using sort_algorithm_type = std::function<void(typename T::iterator,
typename T::iterator,
callback_type<T>)>;
#include "sorts/bubble_sort.hpp"
#include "sorts/quick_sort.hpp"
#include "sorts/insertion_sort.hpp"
#include "sorts/selection_sort.hpp"
#include "sorts/merge_sort.hpp"
/* include more sort algorithms here! */
template <typename T>
std::map<std::string, sort_algorithm_type<T> > algorithms() {
return std::map<std::string, sort_algorithm_type<T> > {
{"bubble", BubbleSort::sort<T>},
{"quick", QuickSort::sort<T>},
{"insertion", InsertionSort::sort<T>},
{"selection", SelectionSort::sort<T>},
{"merge", MergeSort::sort<T>},
/* include more sort algorithms here! */
};
}