Added equality/inequality tests for vector and region.

This commit is contained in:
David Williams
2011-09-24 11:02:01 +01:00
parent ddc54e0862
commit 7bbdb1a29d
9 changed files with 134 additions and 0 deletions

View File

@ -44,6 +44,11 @@ namespace PolyVox
Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner);
Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ);
///Equality Operator.
bool operator==(const Region& rhs) const throw();
///Inequality Operator.
bool operator!=(const Region& rhs) const throw();
const Vector3DInt32& getLowerCorner(void) const;
const Vector3DInt32& getUpperCorner(void) const;

View File

@ -81,6 +81,8 @@ namespace PolyVox
Vector<Size,Type>& operator=(const Vector<Size,Type>& rhs) throw();
///Equality Operator.
bool operator==(const Vector<Size,Type>& rhs) const throw();
///Inequality Operator.
bool operator!=(const Vector<Size,Type>& rhs) const throw();
///Comparison Operator.
bool operator<(const Vector<Size,Type>& rhs) const throw();
///Addition and Assignment Operator.

View File

@ -150,6 +150,18 @@ namespace PolyVox
return equal;
}
/**
Checks whether two Vectors are not equal.
\param rhs The Vector to compare to.
\return true if the Vectors do not match.
\see operator==
*/
template <uint32_t Size, typename Type>
inline bool Vector<Size, Type>::operator!=(const Vector<Size, Type> &rhs) const throw()
{
return !(*this == rhs); //Just call equality operator and invert the result.
}
/**
Checks whether this vector is less than the parameter. The metric is
meaningless but it allows Vectors to me used as key in sdt::map, etc.