Browse Source

TypeHandle::compare_to()

David Rose 23 years ago
parent
commit
d33bc6d7b2
2 changed files with 14 additions and 0 deletions
  1. 13 0
      panda/src/express/typeHandle.I
  2. 1 0
      panda/src/express/typeHandle.h

+ 13 - 0
panda/src/express/typeHandle.I

@@ -104,6 +104,19 @@ operator >= (const TypeHandle &other) const {
   return (_index >= other._index);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: TypeHandle::compare_to
+//       Access: Published
+//  Description: Sorts TypeHandles arbitrarily (according to <, >,
+//               etc.).  Returns a number less than 0 if this type
+//               sorts before the other one, greater than zero if it
+//               sorts after, 0 if they are equivalent.
+////////////////////////////////////////////////////////////////////
+INLINE int TypeHandle::
+compare_to(const TypeHandle &other) const {
+  return _index - other._index;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: TypeHandle::get_name
 //       Access: Published

+ 1 - 0
panda/src/express/typeHandle.h

@@ -99,6 +99,7 @@ PUBLISHED:
   INLINE bool operator <= (const TypeHandle &other) const;
   INLINE bool operator > (const TypeHandle &other) const;
   INLINE bool operator >= (const TypeHandle &other) const;
+  INLINE int compare_to(const TypeHandle &other) const;
 
   INLINE string get_name(TypedObject *object = (TypedObject *)NULL) const;
   INLINE bool is_derived_from(TypeHandle parent,