Skip to content

Commit

Permalink
CAmountMap::operator! to check if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 9, 2019
1 parent af726c7 commit 466b3d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 466b3d0

Please sign in to comment.