From eb05821d40d7eb072a3d6d1d01e8ea6b759cadf2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 22 Feb 2002 19:11:33 +0000 Subject: [PATCH] add compareTo --- panda/src/putil/Sources.pp | 7 +++++-- panda/src/putil/compareTo.I | 29 +++++++++++++++++++++++++++ panda/src/putil/compareTo.h | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 panda/src/putil/compareTo.I create mode 100644 panda/src/putil/compareTo.h diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index ce731070f3..7218e1ca4b 100644 --- a/panda/src/putil/Sources.pp +++ b/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 \ diff --git a/panda/src/putil/compareTo.I b/panda/src/putil/compareTo.I new file mode 100644 index 0000000000..f41495b9a5 --- /dev/null +++ b/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 +// panda3d@yahoogroups.com . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: CompareTo::operator () +// Access: Public +// Description: Returns true if a sorts before b, false otherwise. +//////////////////////////////////////////////////////////////////// +template +INLINE bool CompareTo:: +operator () (const ObjectType &a, const ObjectType &b) const { + return (a.compare_to(b) < 0); +} diff --git a/panda/src/putil/compareTo.h b/panda/src/putil/compareTo.h new file mode 100644 index 0000000000..45ea40c034 --- /dev/null +++ b/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 +// panda3d@yahoogroups.com . +// +//////////////////////////////////////////////////////////////////// + +#ifndef COMPARETO_H +#define COMPARETO_H + +#include + +//////////////////////////////////////////////////////////////////// +// 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 CompareTo { +public: + INLINE bool operator () (const ObjectType &a, const ObjectType &b) const; +}; + +#include "compareTo.I" + +#endif +