compare_to

This commit is contained in:
David Rose 2009-11-09 16:49:55 +00:00
parent f15125ce30
commit 53486852f4
2 changed files with 41 additions and 5 deletions

View File

@ -365,22 +365,55 @@ operator = (const PixelSpec &copy) {
}
////////////////////////////////////////////////////////////////////
// Function: PNMImageHeader::PixelSpec::Comparison Operator
// Function: PNMImageHeader::PixelSpec::operator <
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PNMImageHeader::PixelSpec::
operator < (const PixelSpec &other) const {
return compare_to(other) < 0;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImageHeader::PixelSpec::operator ==
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PNMImageHeader::PixelSpec::
operator == (const PixelSpec &other) const {
return compare_to(other) == 0;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImageHeader::PixelSpec::operator !=
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PNMImageHeader::PixelSpec::
operator != (const PixelSpec &other) const {
return compare_to(other) != 0;
}
////////////////////////////////////////////////////////////////////
// Function: PNMImageHeader::PixelSpec::compare_to
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE int PNMImageHeader::PixelSpec::
compare_to(const PixelSpec &other) const {
if (_red != other._red) {
return _red < other._red;
return _red < other._red ? -1 : 1;
}
if (_green != other._green) {
return _green < other._green;
return _green < other._green ? -1 : 1;
}
if (_blue != other._blue) {
return _blue < other._blue;
return _blue < other._blue ? -1 : 1;
}
return _alpha < other._alpha;
if (_alpha != other._alpha) {
return _alpha < other._alpha ? -1 : 1;
}
return 0;
}
////////////////////////////////////////////////////////////////////

View File

@ -118,6 +118,9 @@ PUBLISHED:
INLINE void operator = (const PixelSpec &copy);
INLINE bool operator < (const PixelSpec &other) const;
INLINE bool operator == (const PixelSpec &other) const;
INLINE bool operator != (const PixelSpec &other) const;
INLINE int compare_to(const PixelSpec &other) const;
INLINE xelval get_red() const;
INLINE xelval get_green() const;