📄 sortall.h
字号:
#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 <class Type>
void InsertSort(tvector<Type> & a, int size);
template <class Type, class Comparer>
void InsertSort(tvector<Type> & a, int size, const Comparer & comp);
template <class Type>
void SelectSort(tvector<Type> & a, int size);
template <class Type, class Comparer>
void SelectSort(tvector<Type> & a, int size, const Comparer & comp);
template <class Type>
void BubbleSort(tvector<Type> & a, int size);
template <class Type>
void MergeSort(tvector<Type> & a,int n);
template <class Type, class Comparer>
void MergeSort(tvector<Type> & a, int n, const Comparer & comp);
template <class Type>
void QuickSort(tvector<Type> & a, int size);
template <class Type, class Compare>
void QuickSort(tvector<Type> & a, int size,const Compare& comp);
template <class Type>
void HeapSort(tvector<Type>& a, int size);
template <class Type>
void Swap(tvector<Type>& v, int j, int k);
// post: v[k] and v[j] swapped
// searching functions
template <class Type>
int bsearch(const tvector<Type>& list, const Type& key);
template <class Type, class Comparer>
int bsearch(const tvector<Type>& list, const Type& key, const Comparer& c);
template <class Type, class Comparer>
int search(const tvector<Type>& list, const Type& key, const Comparer& c);
template <class Type>
int search(const tvector<Type>& list, const Type& key);
#include "sortall.cpp"
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -