00001 00041 #ifndef ABA_SORTER_H 00042 #define ABA_SORTER_H 00043 00044 #include "abacus/array.h" 00045 template <class ItemType, class KeyType> 00046 class ABA_SORTER : public ABA_ABACUSROOT { 00047 public: 00048 00053 ABA_SORTER (ABA_GLOBAL *glob); 00054 00066 void quickSort(int n, ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys); 00067 00084 void quickSort(ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys, 00085 int left, int right); 00086 00108 void heapSort(int n, ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys); 00109 00110 private: 00111 00135 int partition(ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys, 00136 int left, int right); 00137 00138 00152 void buildHeap(int n, ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys); 00153 00169 void heapify(int n, ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys, int root); 00170 00179 void check(int n, ABA_ARRAY<ItemType> &items, ABA_ARRAY<KeyType> &keys); 00180 00183 ABA_GLOBAL *glob_; 00184 00187 ItemType itemSwap_; 00188 00191 KeyType keySwap_; 00192 }; 00193 00194 #include "abacus/sorter.inc" 00195 00196 #endif // ABA_SORTER_H 00197 00198