From ba23c28c2b0483f10a85db3bdea313fcbb7cf631 Mon Sep 17 00:00:00 2001 From: Andreas Meyer Date: Wed, 4 Jul 2007 16:25:33 +0000 Subject: [PATCH] * added #include * moved some support functions/classes from EXACUS to STL_Extensions/iostream: - Benchmark_rep (similar to Output_rep) - a functor Pair_lexicographical_less_than (previously called Product_order in EXACUS) - a functor Handle_id_less_than --- .../include/CGAL/Handle_with_policy.h | 29 +++++++++++++++++ STL_Extension/include/CGAL/function_objects.h | 29 +++++++++++++++++ STL_Extension/include/CGAL/functional_base.h | 1 + iostream/include/CGAL/IO/io.h | 32 +++++++++++++++---- 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/STL_Extension/include/CGAL/Handle_with_policy.h b/STL_Extension/include/CGAL/Handle_with_policy.h index 1a8ebb2e9e3..3b94fe0084d 100644 --- a/STL_Extension/include/CGAL/Handle_with_policy.h +++ b/STL_Extension/include/CGAL/Handle_with_policy.h @@ -1341,6 +1341,35 @@ public: #endif }; +/*\brief + * This class' function call operator test whether one handle's \c id is + * less than the \c id of the other handle. + * + * "Less" is defined in terms of the second template argument, + * which defaults to \c std::less + */ +template > +class Handle_id_less_than { +public: + //! result_type + typedef bool result_type; + //! type of first argument + typedef Handle first_argument_type; + //! type of second argument + typedef Handle second_argument_type; + //! returns \c true iff \c h1.id() < \c h2.id() + bool operator () (Handle h1, Handle h2) { + Less is_less; + return is_less(h1.id(), h2.id()); + } + //! returns \c true iff \c h1.id() < \c h2.id() + bool operator () (Handle h1, Handle h2) const { + Less is_less; + return is_less(h1.id(), h2.id()); + } +}; + + //@} CGAL_END_NAMESPACE diff --git a/STL_Extension/include/CGAL/function_objects.h b/STL_Extension/include/CGAL/function_objects.h index 8db09e8b8ab..c6c3cadfe85 100644 --- a/STL_Extension/include/CGAL/function_objects.h +++ b/STL_Extension/include/CGAL/function_objects.h @@ -521,6 +521,35 @@ inline Compare_to_less compare_to_less(const Op& op) { return Compare_to_less(op); } + +/*!\brief + * Functor class to determine lexicographical order of pairs + */ +template < class T1, class T2, + class Less1 = std::less, class Less2 = std::less > +struct Pair_lexicographical_less_than { + typedef bool result_type; + typedef std::pair first_argument_type; + typedef std::pair second_argument_type; + /*!\brief + * returns \c true iff \c x is lexicograhically smaller than \c y + * using \c Less1 and \c Less2 functors. + */ + bool operator () (const std::pair& x, const std::pair& y) { + Less1 lt1; + Less2 lt2; + + if (lt1(x.first, y.first)) { + return true; + } else if (lt1(y.first, x.first)) { + return false; + } else /* neither is less than the other */ { + return lt2(x.second, y.second); + } + } +}; + + CGAL_END_NAMESPACE #endif // CGAL_FUNCTION_OBJECTS_H diff --git a/STL_Extension/include/CGAL/functional_base.h b/STL_Extension/include/CGAL/functional_base.h index 49b3f252648..38d1b502833 100644 --- a/STL_Extension/include/CGAL/functional_base.h +++ b/STL_Extension/include/CGAL/functional_base.h @@ -27,6 +27,7 @@ #ifndef CGAL_FUNCTIONAL_BASE_H #define CGAL_FUNCTIONAL_BASE_H +#include #include CGAL_BEGIN_NAMESPACE diff --git a/iostream/include/CGAL/IO/io.h b/iostream/include/CGAL/IO/io.h index 29a4ee2d617..0f74ad8a438 100644 --- a/iostream/include/CGAL/IO/io.h +++ b/iostream/include/CGAL/IO/io.h @@ -101,6 +101,32 @@ template Input_rep iformat( T& t) { return Input_rep(t); } + +template +class Benchmark_rep { + const T& t; +public: + //! initialize with a const reference to \a t. + Benchmark_rep( const T& tt) : t(tt) {} + //! perform the output, calls \c operator\<\< by default. + std::ostream& operator()( std::ostream& out) const { + return out << t; + } +}; + +template +std::ostream& operator<<( std::ostream& out, Benchmark_rep rep) { + return rep( out); +} + +template +Benchmark_rep bmformat( const T& t) { return Benchmark_rep(t); } + +template +Benchmark_rep bmformat( const T& t, F) { return Benchmark_rep(t); } + + + IO::Mode get_mode(std::ios& i); @@ -113,9 +139,6 @@ set_binary_mode(std::ios& i); IO::Mode set_pretty_mode(std::ios& i); -IO::Mode -set_benchmark_mode(std::ios& i); - IO::Mode set_mode(std::ios& i, IO::Mode m); @@ -128,9 +151,6 @@ is_ascii(std::ios& i); bool is_binary(std::ios& i); -bool -is_benchmark(std::ios& i); - template < class T > inline void