David Rose 16 年 前
コミット
53486852f4
2 ファイル変更41 行追加5 行削除
  1. 38 5
      panda/src/pnmimage/pnmImageHeader.I
  2. 3 0
      panda/src/pnmimage/pnmImageHeader.h

+ 38 - 5
panda/src/pnmimage/pnmImageHeader.I

@@ -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;
+  }
+  if (_alpha != other._alpha) {
+    return _alpha < other._alpha ? -1 : 1;
   }
-  return _alpha < other._alpha;
+  return 0;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 0
panda/src/pnmimage/pnmImageHeader.h

@@ -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;