23 bool operator()(
const double lhs,
const double rhs)
const = 0;
36 bool operator()(
const double lhs,
const double rhs)
const
37 {
return fabs(lhs) < fabs(rhs); }
45 bool operator()(
const double lhs,
const double rhs)
const
47 return fabs(lhs) > fabs(rhs);
57 bool operator()(
const double lhs,
const double rhs)
const
69 bool operator()(
const double lhs,
const double rhs)
const
85 bool operator()(
const double lhs,
const double rhs)
const
131 return std::sort(v.begin(), v.begin() + nelem,
proxy(*
m_order));
141 std::vector<std::pair<int, double> > w(v.size());
143 for (
size_t i = 0, n = v.size(); i < n; ++i) {
150 std::vector<int> idx(v.size());
152 for (
size_t i = 0, n = v.size(); i < n; ++i) {
167 std::vector<std::pair<int, double> > w(v.size());
169 for (
size_t i = 0, n = v.size(); i < n; ++i) {
174 std::sort(w.begin(), w.begin() + nelem,
proxy(*
m_order));
176 std::vector<int> idx(v.size());
178 for (
size_t i = 0, n = v.size(); i < n; ++i) {
192 return m_order->operator()(lhs, rhs);
proxy(const Sorter::by_order &order)
bool operator()(const pair_t &lhs, const pair_t &rhs) const
void sort(std::vector< double > &v)
sort an array of values; v is sorted on exit.
std::pair< int, double > pair_t
virtual bool operator()(const double lhs, const double rhs) const =0
bool operator()(const double lhs, const double rhs) const
absolute descending order
proxy object to pass to stl sort algorithm
std::vector< int > sort_index(std::vector< double > &v)
sort an array and return list of index; v is sorted on exit.
virtual ~Sorter()
destructor
virtual bool operator()(const double lhs, const double rhs) const
Sorter(const std::string &type)
constructor with sort ordering as a string arg
const Sorter::by_order & m_order
bool operator()(const double lhs, const double rhs) const
bool operator()(const double lhs, const double rhs) const
base class for sort ordering
bool operator()(const pair_t &lhs, const pair_t &rhs) const
bool comp(const double lhs, const double rhs)
call sort condition.
virtual bool operator()(const double lhs, const double rhs) const