operator< again
This commit is contained in:
parent
3736ad2384
commit
f83d3f70b5
1 changed files with 10 additions and 2 deletions
12
Map.hpp
12
Map.hpp
|
@ -629,7 +629,15 @@ public:
|
|||
friend bool operator!=(const Map &lhs, const Map &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
// TODO
|
||||
friend bool operator<(const Map &lhs, const Map &rhs) { return false; }
|
||||
friend bool operator<(const Map &lhs, const Map &rhs) {
|
||||
auto l_iter = lhs.cbegin();
|
||||
auto r_iter = rhs.cbegin();
|
||||
for (; l_iter != lhs.cend() && r_iter != rhs.cend(); l_iter++, r_iter++) {
|
||||
if (*l_iter < *r_iter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return lhs.size() < rhs.size();
|
||||
}
|
||||
};
|
||||
} // namespace cs440
|
||||
|
|
Loading…
Reference in a new issue