* added #include <CGAL/basic>

* 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
This commit is contained in:
Andreas Meyer 2007-07-04 16:25:33 +00:00
parent 893aff0ff3
commit ba23c28c2b
4 changed files with 85 additions and 6 deletions

View File

@ -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<Handle::Id_type>
*/
template <class Handle, class Less = std::less<typename Handle::Id_type> >
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

View File

@ -521,6 +521,35 @@ inline Compare_to_less<Op>
compare_to_less(const Op& op)
{ return Compare_to_less<Op>(op); }
/*!\brief
* Functor class to determine lexicographical order of pairs
*/
template < class T1, class T2,
class Less1 = std::less<T1>, class Less2 = std::less<T2> >
struct Pair_lexicographical_less_than {
typedef bool result_type;
typedef std::pair<T1,T2> first_argument_type;
typedef std::pair<T1,T2> 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<T1,T2>& x, const std::pair<T1,T2>& 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

View File

@ -27,6 +27,7 @@
#ifndef CGAL_FUNCTIONAL_BASE_H
#define CGAL_FUNCTIONAL_BASE_H
#include <CGAL/basic.h>
#include <functional>
CGAL_BEGIN_NAMESPACE

View File

@ -101,6 +101,32 @@ template <class T>
Input_rep<T>
iformat( T& t) { return Input_rep<T>(t); }
template <class T, class F = Null_tag >
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 <class T, class F>
std::ostream& operator<<( std::ostream& out, Benchmark_rep<T,F> rep) {
return rep( out);
}
template <class T>
Benchmark_rep<T> bmformat( const T& t) { return Benchmark_rep<T>(t); }
template <class T, class F>
Benchmark_rep<T,F> bmformat( const T& t, F) { return Benchmark_rep<T,F>(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