00001
00002
00003
00004
00005 #ifndef __J2K__Sort_HPP__
00006 #define __J2K__Sort_HPP__ // To avoid multiple declaration of a class
00007
00008 #include "Const.hpp"
00009 #include "MaxHeap.hpp"
00010
00011 static long POW2[17] = { 1, 2, 4, 8, 16,
00012 32, 64, 128, 256,
00013 512, 1024, 2048, 4096,
00014 8192, 16384, 32768, 65536 };
00015
00016 #define BITS 6
00017
00018 void InsertionSort( Elem* array, int n );
00019 void BubbleSort( Elem* array, int n );
00020 void SelectionSort( Elem* array, int n );
00021 void ShellSort( Elem* array, int n );
00022 void InsertionSort( Elem* array, int n, int incr );
00023
00024 void MergeSort(Elem* array, int Size);
00025 void HeapSort( Elem* array, int Size );
00026 void RadixSort(Elem* array, long Size);
00027
00028 void QuickSort( Elem* array, int Size );
00029 void BrightQSort( Elem* array, ulong Size );
00030 void OldQuickSort( Elem* array, ulong Size );
00031
00032 void MergeSort(Elem* array, Elem* temp, int left, int right);
00033
00034 struct QEntry {
00035 long Left;
00036 long Right;
00037 };
00038
00039
00040 inline void swap( Elem* A, int i, int j )
00041 {
00042 Elem temp = A[i];
00043 A[i] = A[j];
00044 A[j] = temp;
00045 }
00046
00047 #endif // End of Sort.hpp
00048