Go to the documentation of this file.
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
100 if (
type ==
"abs_ascending")
m_order =
new by_abs_ascend;
101 if (
type ==
"abs_descending")
m_order =
new by_abs_descend;
103 if (
type ==
"descending")
m_order =
new by_descend;
121 return std::sort(v.begin(), v.end(), proxy(*
m_order));
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) {
148 std::sort(w.begin(), w.end(), proxy(*
m_order));
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);
bool operator()(const pair_t &lhs, const pair_t &rhs) const
absolute descending order
base class for sort ordering
virtual bool operator()(const double lhs, const double rhs) const
const Sorter::by_order & m_order
Sorter(const std::string &type)
constructor with sort ordering as a string arg
std::pair< int, double > pair_t
bool operator()(const double lhs, const double rhs) const
bool operator()(const double lhs, const double rhs) const
virtual bool operator()(const double lhs, const double rhs) const
bool operator()(const double lhs, const double rhs) const
std::vector< int > sort_index(std::vector< double > &v)
sort an array and return list of index; v is sorted on exit.
proxy(const Sorter::by_order &order)
int idx(const int in, const int Nin, const int ist, const int Nx2, const int Ny, const int leo, const int Nvol2, const int ex)
proxy object to pass to stl sort algorithm
virtual bool operator()(const double lhs, const double rhs) const =0
bool comp(const double lhs, const double rhs)
call sort condition.
void sort(std::vector< double > &v)
sort an array of values; v is sorted on exit.
virtual ~Sorter()
destructor
bool operator()(const pair_t &lhs, const pair_t &rhs) const