#ifndef _SORTALL_H #define _SORTALL_H #include "tvector.h" #include "comparer.h" // ****************** // prototypes for sort functions and search functions // author: Owen Astrachan // // see also: comparer.h, sortall.cpp // // for "plain" sorts, the type being sorted // must be comparable with < and for Merge and Quick also with <= // for sorts with the Comparer template parameter the type // for Comparer (see comparer.h) must have a member function // named compare that takes two const Type arguments: lhs, rhs, // and that returns -1, 0, or +1 if lhs <, ==, > rhs, respectively // // search functions take a Comparer object also // // ******************* template void InsertSort(tvector & a, int size); template void InsertSort(tvector & a, int size, const Comparer & comp); template void SelectSort(tvector & a, int size); template void SelectSort(tvector & a, int size, const Comparer & comp); template void BubbleSort(tvector & a, int size); template void MergeSort(tvector & a,int n); template void MergeSort(tvector & a, int n, const Comparer & comp); template void QuickSort(tvector & a, int size); template void QuickSort(tvector & a, int size,const Compare& comp); template void HeapSort(tvector& a, int size); template void Swap(tvector& v, int j, int k); // post: v[k] and v[j] swapped // searching functions template int bsearch(const tvector& list, const Type& key); template int bsearch(const tvector& list, const Type& key, const Comparer& c); template int search(const tvector& list, const Type& key, const Comparer& c); template int search(const tvector& list, const Type& key); #include "sortall.cpp" #endif