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
|
#if !defined (RADIXSORT_H)
#define RADIXSORT_H
#include "QueueLinked.h"
using CSC2110::QueueLinked;
template < class T >
class RadixSort
{
private:
static char getRadixChar(T* item, int index); //1-based
static void binSort(QueueLinked<T>* bin, int curr_char, int num_chars, char (*getRadixChar) (T* item, int index));
static void radixSortAsc(T** sort, int n, int num_chars, char (*getRadixChar) (T* item, int index)); //algorithm 1
static void radixSortDesc(T** sort, int n, int num_chars, char (*getRadixChar) (T* item, int index)); //algorithm 2
public:
static T** radixSort(T** sort, int num_to_sort, int num_chars, bool asc, char (*getRadixChar) (T* item, int index));
};
template < class T >
T** RadixSort<T>::radixSort(T** unsorted, int num_to_sort, int num_chars, bool asc, char (*getRadixChar) (T* item, int index))
{
//DO THIS
//return unsorted;
//Test stub
//if(asc)
// radixSortAsc(sort, n, num_chars, (*getRadixChar) (st, index));
//else
// radixSortDesc(sort, n, num_chars, (*getRadixChar) (st, index));
}
template < class T >
char RadixSort<T>::getRadixChar(T* item, int index)
{
//return 0;
//Test stub
}
template < class T >
void RadixSort<T>::radixSortAsc(T** sort, int n, int num_chars, char (*getRadixChar) (T* st, int index))
{
//DO THIS
//return;
//Test stub
}
template < class T >
void RadixSort<T>::binSort(QueueLinked<T>* bin, int curr_char, int num_chars, char (*getRadixChar) (T* st, int index))
{
//DO THIS
//return;
//Test stub
}
template < class T >
void RadixSort<T>::radixSortDesc(T** sort, int n, int num_chars, char (*getRadixChar) (T* st, int index))
{
int num_queues = 37; //covers letters and digits
QueueLinked<T>** bins = new QueueLinked<T>*[num_queues];
//must instantiate each of the queues
for (int i = 0; i < num_queues; i++)
{
//DO THIS
}
for (int i = num_chars; i > 0; i--) //number of times to bin stuff
{
//DO THIS
}
for (int i = 0; i < num_queues; i++)
{
delete bins[i];
}
delete[] bins;
}
#endif
| |