From 4d96148508ef4ab7e3cc588c6e26b45bb4da4080 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 27 Jun 2001 19:51:53 +0000 Subject: [PATCH] add indirectLess --- panda/src/putil/Sources.pp | 4 +++- panda/src/putil/indirectLess.I | 29 ++++++++++++++++++++++++ panda/src/putil/indirectLess.h | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 panda/src/putil/indirectLess.I create mode 100644 panda/src/putil/indirectLess.h diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index eeb14039cc..4d497ba36e 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -19,6 +19,7 @@ globalPointerRegistry.I globalPointerRegistry.h \ indirectCompareNames.I indirectCompareNames.h \ indirectCompareTo.I indirectCompareTo.h \ + indirectLess.I indirectLess.h \ ioPtaDatagramFloat.h ioPtaDatagramInt.h \ ioPtaDatagramShort.h keyboardButton.h lineStream.I \ lineStream.h lineStreamBuf.I lineStreamBuf.h \ @@ -64,7 +65,8 @@ globPattern.I globPattern.h \ globalPointerRegistry.I globalPointerRegistry.h \ indirectCompareNames.I indirectCompareNames.h indirectCompareTo.I \ - indirectCompareTo.h ioPtaDatagramFloat.h ioPtaDatagramInt.h \ + indirectCompareTo.h indirectLess.I indirectLess.h \ + ioPtaDatagramFloat.h ioPtaDatagramInt.h \ ioPtaDatagramShort.h iterator_types.h keyboardButton.h lineStream.I \ lineStream.h lineStreamBuf.I lineStreamBuf.h modifierButtons.I \ modifierButtons.h mouseButton.h mouseData.h nameUniquifier.I \ diff --git a/panda/src/putil/indirectLess.I b/panda/src/putil/indirectLess.I new file mode 100644 index 0000000000..5eacd0c1a9 --- /dev/null +++ b/panda/src/putil/indirectLess.I @@ -0,0 +1,29 @@ +// Filename: indirectLess.I +// Created by: drose (27Jun01) +// +//////////////////////////////////////////////////////////////////// +// +// 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: IndirectLess::operator () +// Access: Public +// Description: Returns true if a sorts before b, false otherwise. +//////////////////////////////////////////////////////////////////// +template +INLINE bool IndirectLess:: +operator () (const ObjectType *a, const ObjectType *b) const { + return (a != b && (*a) < (*b)); +} diff --git a/panda/src/putil/indirectLess.h b/panda/src/putil/indirectLess.h new file mode 100644 index 0000000000..0a1fbe1775 --- /dev/null +++ b/panda/src/putil/indirectLess.h @@ -0,0 +1,40 @@ +// Filename: indirectLess.h +// Created by: drose (27Jun01) +// +//////////////////////////////////////////////////////////////////// +// +// 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 INDIRECTLESS_H +#define INDIRECTLESS_H + +#include + +//////////////////////////////////////////////////////////////////// +// Class : IndirectLess +// Description : An STL function object class, this is intended to be +// used on any ordered collection of pointers to classes +// that contain an operator <() method. It defines the +// order of the pointers via operator <(). +//////////////////////////////////////////////////////////////////// +template +class IndirectLess { +public: + INLINE bool operator () (const ObjectType *a, const ObjectType *b) const; +}; + +#include "indirectLess.I" + +#endif +