ezEngine  Milestone 7
Sorting.h
1 
2 #pragma once
3 
4 #include <Foundation/Basics.h>
5 #include <Foundation/Algorithm/Comparer.h>
6 #include <Foundation/Math/Math.h>
7 
9 class ezSorting
10 {
11 public:
13  template <typename Container, typename Comparer>
14  static void QuickSort(Container& container, const Comparer& comparer = Comparer()); // [tested]
15 
17  template <typename T, typename Comparer>
18  static void QuickSort(ezArrayPtr<T>& arrayPtr, const Comparer& comparer = Comparer()); // [tested]
19 
20 
22  template <typename Container, typename Comparer>
23  static void InsertionSort(Container& container, const Comparer& comparer = Comparer()); // [tested]
24 
26  template <typename T, typename Comparer>
27  static void InsertionSort(ezArrayPtr<T>& arrayPtr, const Comparer& comparer = Comparer()); // [tested]
28 
29 private:
30  enum { INSERTION_THRESHOLD = 16 };
31 
32  template <typename Container, typename Comparer>
33  static void QuickSort(Container& container, ezUInt32 uiStartIndex, ezUInt32 uiEndIndex, const Comparer& comparer);
34 
35  template <typename Container, typename Comparer>
36  static ezUInt32 Partition(Container& container, ezUInt32 uiLeft, ezUInt32 uiRight, const Comparer& comparer);
37 
38 
39  template <typename T, typename Comparer>
40  static void QuickSort(ezArrayPtr<T>& arrayPtr, ezUInt32 uiStartIndex, ezUInt32 uiEndIndex, const Comparer& comparer);
41 
42  template <typename T, typename Comparer>
43  static ezUInt32 Partition(ezArrayPtr<T>& arrayPtr, ezUInt32 uiLeft, ezUInt32 uiRight, const Comparer& comparer);
44 
45 
46  template <typename Container, typename Comparer>
47  static void InsertionSort(Container& container, ezUInt32 uiStartIndex, ezUInt32 uiEndIndex, const Comparer& comparer);
48 
49  template <typename T, typename Comparer>
50  static void InsertionSort(ezArrayPtr<T>& arrayPtr, ezUInt32 uiStartIndex, ezUInt32 uiEndIndex, const Comparer& comparer);
51 };
52 
53 #include <Foundation/Algorithm/Implementation/Sorting_inl.h>
54