From: clinton Date: Thu, 13 Nov 2008 11:25:57 +0000 (+0000) Subject: Add indirect comparison predicate X-Git-Tag: release-2.3.1~45 X-Git-Url: https://git.hcoop.net/clinton/bobotpp.git/commitdiff_plain/643f62be9dc4a1126754b9ff16b06a45b72e258f Add indirect comparison predicate * Used to sort containers of pointers using the pointed to objects' comparison methods --- diff --git a/source/Utils.H b/source/Utils.H index c1b4741..ff1f6d7 100644 --- a/source/Utils.H +++ b/source/Utils.H @@ -1,6 +1,6 @@ // Utils.H -*- C++ -*- // Copyright (c) 1997, 1998 Etienne BERNARD -// Copyright (c) 2002,2005 Clinton Ebadi +// Copyright (c) 2002,2005,2008 Clinton Ebadi // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -67,6 +67,19 @@ namespace Utils { std::string scm2str (SCM); SCM str2scm (std::string); #endif + + // Class to compare *i1 / *i2 in heaps etc. + template class IndirectPred + { + C compare; + public: + bool operator() (const T * i1, const T * i2) const + { return compare (*i1, *i2); } + + typedef T* first_argument_type; + typedef T* second_argument_type; + typedef bool result_type; + }; } #endif