Dynalib Utils
DynaSort.h
Go to the documentation of this file.
1 
12 #ifndef DYNASORT_H
13 #define DYNASORT_H
14 
15 #include "DynaList.h"
16 #include "DynaArray.h"
17 #include "DynaAlloc.h"
18 #include "IDynaComparator.h"
19 
25 static const int INSERTION_SORT_THRESHOLD = 7;
26 
27 
32 #define MAKE_SORTLISTTYPE_DEF(C, T) \
33  typedef DynaAllocVect<C> T##AllocVect; \
34  typedef DynaSortList<C> T##SortList
35 
40 #define MAKE_SORTARRAYTYPE_DEF(C, T) \
41  typedef DynaAllocArray<C> T##AllocArray; \
42  typedef DynaSortArray<C> T##SortArray
43 
44 template <class T> class DynaSortList {
45 protected:
46  static void _mergeSort( T** src, T** dest, int low, int high, IDynaComparator<T*>& comparator );
47  static void _swap( T** x, int a, int b );
48 
49 public:
59  static void mergeSort( T** array, int length, int low, int high, IDynaComparator<T*>& comparator );
60  static void mergeSort( T** array, int length, IDynaComparator<T*>& comparator );
61 
70  static void mergeSort( DynaList<T>* list, int low, int high, IDynaComparator<T*>& comparator );
71  static void mergeSort( DynaList<T>* list, IDynaComparator<T*>& comparator );
72 };
73 
74 template <class T> class DynaSortArray {
75 protected:
76  static void _mergeSort( T* src, T* dest, int low, int high, IDynaComparator<T>& comparator );
77  static void _swap( T* x, int a, int b );
78 
79 public:
89  static void mergeSort( T* array, int length, int low, int high, IDynaComparator<T>& comparator );
90  static void mergeSort( T* array, int length, IDynaComparator<T>& comparator );
91 
100  static void mergeSort( DynaArray<T>* array, int low, int high, IDynaComparator<T>& comparator );
101  static void mergeSort( DynaArray<T>* array, IDynaComparator<T>& comparator );
102 };
103 
104 
105 #endif
static void mergeSort(T **array, int length, int low, int high, IDynaComparator< T *> &comparator)
Sort an array of objects, typically those allocated with "new".
Definition: DynaSortImpl.h:68
Definition: IDynaComparator.h:19
Definition: DynaSort.h:74
static void _swap(T **x, int a, int b)
Definition: DynaSortImpl.h:35
Definition: DynaList.h:38
Definition: DynaArray.h:28
static void _mergeSort(T **src, T **dest, int low, int high, IDynaComparator< T *> &comparator)
Definition: DynaSortImpl.h:41
Definition: DynaSort.h:44