CAmountMap::operator! to check if empty

This commit is contained in:
Luke Dashjr 2019-01-07 16:00:34 +00:00 committed by Gregory Sanders
parent af726c7c36
commit 466b3d03f5
2 changed files with 9 additions and 0 deletions

View file

@ -121,6 +121,14 @@ bool operator!=(const CAmountMap& a, const CAmountMap& b)
return !(a == b);
}
bool operator!(const CAmountMap& a)
{
for (const auto& it : a) {
if (it.second) return false;
}
return true;
}
bool hasNegativeValue(const CAmountMap& amount)
{
for(std::map<CAsset, CAmount>::const_iterator it = amount.begin(); it != amount.end(); ++it) {

View file

@ -93,6 +93,7 @@ bool operator>(const CAmountMap& a, const CAmountMap& b);
bool operator>=(const CAmountMap& a, const CAmountMap& b);
bool operator==(const CAmountMap& a, const CAmountMap& b);
bool operator!=(const CAmountMap& a, const CAmountMap& b);
bool operator!(const CAmountMap& a); // Check if all values are 0
inline bool MoneyRange(const CAmountMap& mapValue) {
for(CAmountMap::const_iterator it = mapValue.begin(); it != mapValue.end(); it++) {