Merge pull request #8928 from Svenito/vec_op

Add greater than operator to Vec2
This commit is contained in:
minggo 2014-10-27 11:54:23 +08:00
commit 34c2587f7c
2 changed files with 18 additions and 0 deletions

View File

@ -418,6 +418,15 @@ public:
* @return True if this vector is less than the given vector, false otherwise.
*/
inline bool operator<(const Vec2& v) const;
/**
* Determines if this vector is greater than the given vector.
*
* @param v The vector to compare against.
*
* @return True if this vector is greater than the given vector, false otherwise.
*/
inline bool operator>(const Vec2& v) const;
/**
* Determines if this vector is equal to the given vector.

View File

@ -82,6 +82,15 @@ inline bool Vec2::operator<(const Vec2& v) const
return x < v.x;
}
inline bool Vec2::operator>(const Vec2& v) const
{
if (x == v.x)
{
return y > v.y;
}
return x > v.x;
}
inline bool Vec2::operator==(const Vec2& v) const
{
return x==v.x && y==v.y;