Refactored some comparison helper classes
This commit is contained in:
parent
9d61d3d621
commit
6870c54644
4 changed files with 9 additions and 8 deletions
|
|
@ -271,7 +271,8 @@ void balance_t::print(std::ostream& out,
|
|||
if (pair.second)
|
||||
sorted.push_back(&pair.second);
|
||||
|
||||
std::stable_sort(sorted.begin(), sorted.end(), compare_amount_commodities());
|
||||
std::stable_sort(sorted.begin(), sorted.end(),
|
||||
commodity_t::compare_by_commodity());
|
||||
|
||||
foreach (const amount_t * amount, sorted) {
|
||||
int width;
|
||||
|
|
|
|||
|
|
@ -587,8 +587,8 @@ bool commodity_t::valid() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool compare_amount_commodities::operator()(const amount_t * left,
|
||||
const amount_t * right) const
|
||||
bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
|
||||
const amount_t * right) const
|
||||
{
|
||||
commodity_t& leftcomm(left->commodity());
|
||||
commodity_t& rightcomm(right->commodity());
|
||||
|
|
|
|||
|
|
@ -386,6 +386,10 @@ public:
|
|||
|
||||
bool valid() const;
|
||||
|
||||
struct compare_by_commodity {
|
||||
bool operator()(const amount_t * left, const amount_t * right) const;
|
||||
};
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
supports_flags<uint_least16_t> temp_flags;
|
||||
|
|
@ -419,10 +423,6 @@ inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) {
|
|||
return out;
|
||||
}
|
||||
|
||||
struct compare_amount_commodities {
|
||||
bool operator()(const amount_t * left, const amount_t * right) const;
|
||||
};
|
||||
|
||||
void to_xml(std::ostream& out, const commodity_t& comm,
|
||||
bool commodity_details = false);
|
||||
|
||||
|
|
|
|||
|
|
@ -861,7 +861,7 @@ bool value_t::is_less_than(const value_t& val) const
|
|||
return as_amount() < val.as_amount();
|
||||
}
|
||||
catch (const amount_error&) {
|
||||
return compare_amount_commodities()(&as_amount(), &val.as_amount());
|
||||
return commodity_t::compare_by_commodity()(&as_amount(), &val.as_amount());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue