Explorar el Código

add compareTo

David Rose hace 24 años
padre
commit
eb05821d40
Se han modificado 3 ficheros con 74 adiciones y 2 borrados
  1. 5 2
      panda/src/putil/Sources.pp
  2. 29 0
      panda/src/putil/compareTo.I
  3. 40 0
      panda/src/putil/compareTo.h

+ 5 - 2
panda/src/putil/Sources.pp

@@ -12,8 +12,10 @@
      bamReaderParam.h bamWriter.I bamWriter.h bitMask.I \
      bitMask.h buttonEvent.I buttonEvent.h buttonHandle.I \
      buttonHandle.h buttonRegistry.I buttonRegistry.h \
-     collideMask.h config_util.N config_util.h \
-     configurable.h factoryBase.I factoryBase.h \
+     collideMask.h \
+     compareTo.I compareTo.h \
+     config_util.N config_util.h configurable.h \
+     factoryBase.I factoryBase.h \
      factoryParam.I factoryParam.h factoryParams.I \
      factoryParams.h \
      firstOfPairCompare.I firstOfPairCompare.h \
@@ -65,6 +67,7 @@
     bamWriter.I bamWriter.h bitMask.I bitMask.h buttonEvent.I \
     buttonEvent.h buttonHandle.I buttonHandle.h buttonRegistry.I \
     buttonRegistry.h collideMask.h \
+    compareTo.I compareTo.h \
     config_util.h configurable.h factory.I factory.h \
     factoryBase.I factoryBase.h factoryParam.I factoryParam.h \
     factoryParams.I factoryParams.h \

+ 29 - 0
panda/src/putil/compareTo.I

@@ -0,0 +1,29 @@
+// Filename: compareTo.I
+// Created by:  drose (22Feb02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: CompareTo::operator ()
+//       Access: Public
+//  Description: Returns true if a sorts before b, false otherwise.
+////////////////////////////////////////////////////////////////////
+template<class ObjectType>
+INLINE bool CompareTo<ObjectType>::
+operator () (const ObjectType &a, const ObjectType &b) const {
+  return (a.compare_to(b) < 0);
+}

+ 40 - 0
panda/src/putil/compareTo.h

@@ -0,0 +1,40 @@
+// Filename: compareTo.h
+// Created by:  drose (22Feb02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef COMPARETO_H
+#define COMPARETO_H
+
+#include <pandabase.h>
+
+////////////////////////////////////////////////////////////////////
+//       Class : CompareTo
+// Description : An STL function object class, this is intended to be
+//               used on any ordered collection of classes that
+//               contain a compare_to() method.  It defines the order
+//               of the pointers via compare_to().
+////////////////////////////////////////////////////////////////////
+template<class ObjectType>
+class CompareTo {
+public:
+  INLINE bool operator () (const ObjectType &a, const ObjectType &b) const;
+};
+
+#include "compareTo.I"
+
+#endif
+