add operator<, -, -=

This commit is contained in:
Glenn Maynard
2006-09-08 04:08:05 +00:00
parent d93a57c841
commit 99f9d8d33c
2 changed files with 11 additions and 0 deletions
+7
View File
@@ -105,6 +105,13 @@ float RageTimer::operator-(const RageTimer &rhs) const
return Difference(*this, rhs);
}
bool RageTimer::operator<( const RageTimer &rhs ) const
{
if( m_secs != rhs.m_secs ) return m_secs < rhs.m_secs;
return m_us < rhs.m_us;
}
RageTimer RageTimer::Sum(const RageTimer &lhs, float tm)
{
/* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25
+4
View File
@@ -29,11 +29,15 @@ public:
/* Add (or subtract) a duration from a timestamp. The result is another timestamp. */
RageTimer operator+( float tm ) const;
RageTimer operator-( float tm ) const { return *this + -tm; }
void operator+=( float tm ) { *this = *this + tm; }
void operator-=( float tm ) { *this = *this + -tm; }
/* Find the amount of time between two timestamps. The result is a duration. */
float operator-( const RageTimer &rhs ) const;
bool operator<( const RageTimer &rhs ) const;
/* "float" is bad for a "time since start" RageTimer. If the game is running for
* several days, we'll lose a lot of resolution. I don't want to use double
* everywhere, since it's slow. I'd rather not use double just for RageTimers, since