Use operator overloading best practices.
Not all files covered. Refer to StackOverflow for details: http://stackoverflow.com/a/4421719
This commit is contained in:
+33
-10
@@ -136,18 +136,41 @@ struct BMSObject
|
||||
float position;
|
||||
bool flag;
|
||||
RString value;
|
||||
bool operator<(const BMSObject &other) const
|
||||
{
|
||||
if( measure < other.measure ) return true;
|
||||
if( measure > other.measure ) return false;
|
||||
if( position < other.position ) return true;
|
||||
if( position > other.position ) return false;
|
||||
if( channel == 1 ) return false;
|
||||
if( other.channel == 1 ) return true;
|
||||
return channel < other.channel;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator<(BMSObject const &lhs, BMSObject const &rhs)
|
||||
{
|
||||
if (lhs.measure != rhs.measure)
|
||||
{
|
||||
return lhs.measure < rhs.measure;
|
||||
}
|
||||
if (lhs.position != rhs.position)
|
||||
{
|
||||
return lhs.position < rhs.position;
|
||||
}
|
||||
if (lhs.channel == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (rhs.channel == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return lhs.channel < rhs.channel;
|
||||
}
|
||||
inline bool operator>(BMSObject const &lhs, BMSObject const &rhs)
|
||||
{
|
||||
return operator<(rhs, lhs);
|
||||
}
|
||||
inline bool operator<=(BMSObject const &lhs, BMSObject const &rhs)
|
||||
{
|
||||
return !operator<(rhs, lhs);
|
||||
}
|
||||
inline bool operator>=(BMSObject const &lhs, BMSObject const &rhs)
|
||||
{
|
||||
return !operator<(lhs, rhs);
|
||||
}
|
||||
|
||||
struct BMSMeasure
|
||||
{
|
||||
float size;
|
||||
|
||||
Reference in New Issue
Block a user