last update 20 Sep 2009 |
#include <cvrSort.h>
Classes | |
class | parameters |
The parameters for the class sort. More... | |
Public Member Functions | |
sort (const eSortingOrder sortingOrder=Ascending) | |
sort (const parameters &par) | |
sort (const sort &other) | |
virtual | ~sort () |
template<class T > | |
bool | apply (matrix< T > &srcdest) const |
template<class T > | |
bool | apply (vector< T > &srcdest) const |
template<class T > | |
bool | apply (const matrix< T > &src, matrix< T > &dest) const |
template<class T > | |
bool | apply (const vector< T > &src, vector< T > &dest) const |
sort & | copy (const sort &other) |
virtual const std::string & | name () const |
virtual sort * | clone () const |
virtual sort * | newInstance () const |
const parameters & | getParameters () const |
bool | updateParameters () |
This class is used to sort the elements of a given vector or matrix.
The sort::parameters::order specify if the elements should be sorted in ascending or descending order.
This functor requires that the type T accept the operator<.
The quick-sort is not "stable", this means that elements with the same key value can change their positions in the vector.
You should also revise the STL algorithms std::sort() if you are using containers of the STL.
cvr::sort::sort | ( | const eSortingOrder | sortingOrder = Ascending |
) |
Default constructor.
cvr::sort::sort | ( | const parameters & | par | ) |
Construct with given parameters.
virtual cvr::sort::~sort | ( | ) | [virtual] |
Destructor.
bool cvr::sort::apply | ( | const vector< T > & | src, | |
vector< T > & | dest | |||
) | const [inline] |
Operates on a copy of the given parameters.
src | vector<T> with the source data. | |
dest | vector<T> where the result will be left. |
bool cvr::sort::apply | ( | const matrix< T > & | src, | |
matrix< T > & | dest | |||
) | const [inline] |
Sort all the elements of the matrix.
The elements will be ordered row-wise. For example, the matrix at the left will be sorted into the matrix at the right side:
| 2 8 3 | | 1 2 3 | | 1 4 5 | ---> | 4 5 6 | | 7 9 6 | | 7 8 9 |
src | matrix<T> with the source data. | |
dest | matrix<T> where the result will be left. |
bool cvr::sort::apply | ( | vector< T > & | srcdest | ) | const [inline] |
Operates on the given parameter.
srcdest | vector<T> with the source data. The result will be left here too. |
bool cvr::sort::apply | ( | matrix< T > & | srcdest | ) | const [inline] |
Sort all the elements of the matrix.
The elements will be ordered row-wise. For example, the matrix at the left will be sorted into the matrix at the right side:
| 2 8 3 | | 1 2 3 | | 1 4 5 | ---> | 4 5 6 | | 7 9 6 | | 7 8 9 |
srcdest | matrix<T> with the source data. The result will be left here too. |
virtual sort* cvr::sort::clone | ( | ) | const [virtual] |
const parameters& cvr::sort::getParameters | ( | ) | const |
virtual const std::string& cvr::sort::name | ( | ) | const [virtual] |
virtual sort* cvr::sort::newInstance | ( | ) | const [virtual] |
bool cvr::sort::updateParameters | ( | ) | [virtual] |