added qhash functions for timerange and rational

So these keys can be used in QHash containers, they need functions for how to
create those hashes.
This commit is contained in:
itsmattkc
2019-11-15 13:55:05 +09:00
parent 336b3a8e05
commit 16f80386e8
4 changed files with 17 additions and 9 deletions
+7 -7
View File
@@ -41,14 +41,9 @@ void TimeRange::set_range(const rational &in, const rational &out)
normalize();
}
bool TimeRange::operator<(const TimeRange &r) const
bool TimeRange::operator==(const TimeRange &r) const
{
return (in() + out()) < (r.in() + r.out());
}
bool TimeRange::operator>(const TimeRange &r) const
{
return (in() + out()) > (r.in() + r.out());
return in() == r.in() && out() == r.out();
}
void TimeRange::normalize()
@@ -63,3 +58,8 @@ void TimeRange::normalize()
// Calculate length
length_ = out_ - in_;
}
uint qHash(const TimeRange &r, uint seed)
{
return qHash(r.in(), seed) ^ qHash(r.out(), seed);
}