mirror of https://github.com/CGAL/cgal
merged changes from CGAL_with_EXACUS branch into trunk.
revisions used: (1) 32995:34537 (2) 34538:34906
This commit is contained in:
parent
c88e6266b6
commit
e9e8387260
|
|
@ -2634,3 +2634,4 @@ Visibility_complex/doc_tex/fig/points.gif -text svneol=unset#image/gif
|
||||||
Visibility_complex/doc_tex/fig/vis-complex.eps -text svneol=unset#application/postscript
|
Visibility_complex/doc_tex/fig/vis-complex.eps -text svneol=unset#application/postscript
|
||||||
Visibility_complex/doc_tex/fig/vis-complex.fig -text svneol=unset#application/octet-stream
|
Visibility_complex/doc_tex/fig/vis-complex.fig -text svneol=unset#application/octet-stream
|
||||||
Visibility_complex/doc_tex/fig/vis-complex.gif -text svneol=unset#image/gif
|
Visibility_complex/doc_tex/fig/vis-complex.gif -text svneol=unset#image/gif
|
||||||
|
iostream/test/iostream/data/io.cin -text
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,13 @@
|
||||||
|
|
||||||
#elif BENCH_NT == NIX_LEDA_FIELD_WITH_SQRT_NT
|
#elif BENCH_NT == NIX_LEDA_FIELD_WITH_SQRT_NT
|
||||||
#include <NiX/Arithmetic_traits.h>
|
#include <NiX/Arithmetic_traits.h>
|
||||||
#if !LiS_HAVE_LEDA
|
#if ! defined(CGAL_USE_LEDA)
|
||||||
#error "Leda not supported"
|
#error "Leda not supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif BENCH_NT == NIX_CORE_FIELD_WITH_SQRT_NT
|
#elif BENCH_NT == NIX_CORE_FIELD_WITH_SQRT_NT
|
||||||
#include <NiX/Arithmetic_traits.h>
|
#include <NiX/Arithmetic_traits.h>
|
||||||
#if !LiS_HAVE_CORE
|
#if !defined(CGAL_USE_CORE)
|
||||||
#error "Core not supported!"
|
#error "Core not supported!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
|
||||||
//
|
//
|
||||||
// Author(s) : script by Geert-Jan Giezeman and Sven Schoenherr
|
//
|
||||||
|
// Author(s) : script by Geert-Jan Giezeman and Sven Schoenherr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
// assertions
|
// assertions
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
|
#ifndef CGAL_KERNEL_ASSERTIONS_H
|
||||||
|
#define CGAL_KERNEL_ASSERTIONS_H
|
||||||
|
|
||||||
#if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \
|
#if defined(CGAL_KERNEL_NO_ASSERTIONS) || defined(CGAL_NO_ASSERTIONS) \
|
||||||
|| defined(NDEBUG)
|
|| defined(NDEBUG)
|
||||||
|
|
@ -284,4 +286,4 @@
|
||||||
# define CGAL_kernel_expensive_exactness_warnings 1
|
# define CGAL_kernel_expensive_exactness_warnings 1
|
||||||
#endif // CGAL_KERNEL_NO_WARNINGS
|
#endif // CGAL_KERNEL_NO_WARNINGS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ Point_set_2
|
||||||
Polygon
|
Polygon
|
||||||
Polyhedron
|
Polyhedron
|
||||||
Polyhedron_IO
|
Polyhedron_IO
|
||||||
|
Polynomial
|
||||||
NefPolynomial
|
NefPolynomial
|
||||||
Polytope_distance_d
|
Polytope_distance_d
|
||||||
Principal_component_analysis
|
Principal_component_analysis
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,171 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : Support
|
||||||
|
// File : include/LiS/Cache.h
|
||||||
|
// SoX_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Michael Hemmer <hemmer@informatik.uni-mainz.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#ifndef CGAL_CACHE_H
|
||||||
|
#define CGAL_CACHE_H 1
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/LiS/basic.h>
|
||||||
|
#include <CGAL/function_objects.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*! \brief The Cache serves as a constructor for an object of type Output from
|
||||||
|
* a object of type Input.
|
||||||
|
*
|
||||||
|
* The Cache internally uses the class std::map<Input_, Output_,Compare_>.
|
||||||
|
* The Cache works as follows. First the \c input is canonicalized by the
|
||||||
|
* Canonicalizer and the result is used as the key of the cache. If the
|
||||||
|
* respective object is not in the cache yet, it is constructed by the Creator
|
||||||
|
* functor from the canonicalized \c input and added to the map.\n
|
||||||
|
*
|
||||||
|
* The Compare functor serves as the key comparison function, which must
|
||||||
|
* define a total ordering on the Input. \n
|
||||||
|
*
|
||||||
|
* The default for the Creator_ functor is Creator_1<Input_,Output_>.\n
|
||||||
|
* The default for the Canonicalizer_ functor is Creator_1<Input_,
|
||||||
|
* Input_> \n
|
||||||
|
* The default for the Compare_ functor is std::less<Input_>. \n
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
template < class Input_,
|
||||||
|
class Output_,
|
||||||
|
class Creator_ = Creator_1<Input_, Output_>,
|
||||||
|
class Canonicalizer_ = Creator_1<Input_, Input_>,
|
||||||
|
class Compare_ = std::less<Input_> >
|
||||||
|
class Cache{
|
||||||
|
public:
|
||||||
|
//! The Input type of the Cache
|
||||||
|
typedef Input_ Input;
|
||||||
|
|
||||||
|
//! The Output type of the Cache
|
||||||
|
typedef Output_ Output;
|
||||||
|
|
||||||
|
/*! \brief The Creator functor of the Cache
|
||||||
|
* This functor is used to create the output from the input.
|
||||||
|
* If Output has a constructor from input you can use the default.*/
|
||||||
|
typedef Creator_ Creator;
|
||||||
|
|
||||||
|
/*! \brief The Canonicalizer functor of the Cache
|
||||||
|
* This functor is used to canonicalize the input in advance. \n
|
||||||
|
* If the Input already is canonicalized you can use the default.\n */
|
||||||
|
typedef Canonicalizer_ Canonicalizer;
|
||||||
|
|
||||||
|
/*! \brief The Compare functor used by the Cache */
|
||||||
|
typedef Compare_ Compare;
|
||||||
|
|
||||||
|
typedef Cache<Input,Output,Creator,Canonicalizer,Compare> Self;
|
||||||
|
private:
|
||||||
|
typedef std::map<Input,Output,Compare> Map;
|
||||||
|
Map map;
|
||||||
|
public:
|
||||||
|
typedef Map _Rep_type;
|
||||||
|
//! Iterator type
|
||||||
|
typedef typename _Rep_type::iterator Iterator;
|
||||||
|
//! Const_iterator type
|
||||||
|
typedef typename _Rep_type::const_iterator Const_iterator;
|
||||||
|
//! Reverse_iterator type
|
||||||
|
typedef typename _Rep_type::reverse_iterator Reverse_iterator;
|
||||||
|
//! Const_reverse_iterator type
|
||||||
|
typedef typename _Rep_type::const_reverse_iterator Const_reverse_iterator;
|
||||||
|
//! Size_type type
|
||||||
|
typedef typename _Rep_type::size_type Size_type;
|
||||||
|
public:
|
||||||
|
//! default constructor with empty table
|
||||||
|
Cache() : map() {};
|
||||||
|
|
||||||
|
/*! \brief Returns the respective object of type Output.
|
||||||
|
*
|
||||||
|
* If the object is not in the cache, it is constructed form \c key and
|
||||||
|
* added to the cache.
|
||||||
|
*/
|
||||||
|
Output operator () (const Input& input) {
|
||||||
|
Canonicalizer canonicalize;
|
||||||
|
Input key = canonicalize(input);
|
||||||
|
typename Map::iterator it = map.find(key);
|
||||||
|
if (it == map.end()) {
|
||||||
|
Creator create;
|
||||||
|
Output out = create(key);
|
||||||
|
map.insert(it,typename Map::value_type(key,out));
|
||||||
|
return out;
|
||||||
|
} else {
|
||||||
|
return (*it).second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Clears the cache contents
|
||||||
|
void clear() { map.clear(); }
|
||||||
|
|
||||||
|
//! Returns whether the cache is empty.
|
||||||
|
bool is_empty() const { return map.empty(); }
|
||||||
|
|
||||||
|
//! Returns the current number of different objects in the cache
|
||||||
|
Size_type size() { return map.size(); }
|
||||||
|
|
||||||
|
//! Returns the largest possible size of the cache.
|
||||||
|
Size_type max_size() const { return map.max_size(); }
|
||||||
|
|
||||||
|
//! Returns an Iterator pointing to the beginning of the cache.
|
||||||
|
Iterator begin() { return map.begin(); }
|
||||||
|
|
||||||
|
//! Returns an Iterator pointing to the end of the cache.
|
||||||
|
Iterator end() { return map.end(); }
|
||||||
|
|
||||||
|
//! Returns a Const_iterator pointing to the beginning of the cache.
|
||||||
|
Const_iterator begin() const { return map.begin(); }
|
||||||
|
|
||||||
|
//! Returns a Const_iterator pointing to the end of the cache.
|
||||||
|
Const_iterator end() const { return map.end(); }
|
||||||
|
|
||||||
|
/*! \brief Returns a Reverse_iterator pointing to the beginning of the
|
||||||
|
* reversed cache.
|
||||||
|
*/
|
||||||
|
Reverse_iterator rbegin() { return map.rbegin(); }
|
||||||
|
|
||||||
|
/*! \brief Returns a Reverse_iterator pointing to the end of the reversed
|
||||||
|
* cache.
|
||||||
|
*/
|
||||||
|
Reverse_iterator rend() { return map.rend(); }
|
||||||
|
|
||||||
|
/*! \brief Returns a Const_reverse_iterator pointing to the beginning of
|
||||||
|
* the reversed cache.
|
||||||
|
*/
|
||||||
|
Const_reverse_iterator rbegin() const { return map.rbegin(); }
|
||||||
|
|
||||||
|
/*! \brief Returns a Const_reverse_iterator pointing to the end of the
|
||||||
|
* reversed cache.
|
||||||
|
*/
|
||||||
|
Const_reverse_iterator rend() const { return map.rend(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// EOF
|
||||||
|
|
@ -0,0 +1,287 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : LiS
|
||||||
|
// File : include/LiS/Flattening_iterator.h
|
||||||
|
// LiS_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Arno Eigenwillig <arno@mpi-inf.mpg.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
/*! \file LiS/Flattening_iterator.h
|
||||||
|
* \brief declares classes \c LiS::Flattening_iterator and
|
||||||
|
* \c LiS::Flattening_const_iterator together with classes
|
||||||
|
* \c LiS::Recursive_flattening and \c LiS::Recursive_const_flattening
|
||||||
|
* for their nested application.
|
||||||
|
* See \link LiS_Flattening_iterator here\endlink.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CGAL_FLATTENING_ITERATOR_H
|
||||||
|
#define CGAL_FLATTENING_ITERATOR_H 1
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/LiS/basic.h>
|
||||||
|
#include <CGAL/Nested_iterator.h>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// LiS2CGAL check whether Nested_iterator in CGAL works in STL_extensions
|
||||||
|
|
||||||
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*! \ingroup LiS_iterator
|
||||||
|
* \defgroup LiS_Flattening_iterator Flattening iterators
|
||||||
|
* Suppose you have an iterator range and suppose further that
|
||||||
|
* the values in that iterator range are containers and thus
|
||||||
|
* define iterator ranges themselves (accessible through
|
||||||
|
* some \c begin and \c end functions).
|
||||||
|
* \e Flattening the iterator range means to turn it into one
|
||||||
|
* iterator range whose values are the values of the containers
|
||||||
|
* in the original range.
|
||||||
|
* For example, a range of lists (1,2),(3),(4,5,6) can be
|
||||||
|
* flattened into a range 1,2,3,4,5,6
|
||||||
|
*
|
||||||
|
* The class templates \c LiS::Flattening_iterator and
|
||||||
|
* \c LiS::Flattening_const_iterator implement this flattening.
|
||||||
|
* So far, only the \c const version has been implemented,
|
||||||
|
* i.e. the values in the flattened range are read-only.
|
||||||
|
*
|
||||||
|
* But what about an iterator range whose values are lists of
|
||||||
|
* vectors of vectors of ... and so on?
|
||||||
|
* Yes, it is possible to flatten such nested containers, too,
|
||||||
|
* by recursive application of \c LiS::Flattening*_iterator.
|
||||||
|
* The class templates \c LiS::Recursive_flattening and
|
||||||
|
* \c LiS::Recursive_const_flattening offer the necessary
|
||||||
|
* typedefs and conversions.
|
||||||
|
* So far, only the \c const version has been implemented.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <int level_, class InputIterator>
|
||||||
|
class Recursive_const_flattening;
|
||||||
|
|
||||||
|
template <class InputIterator>
|
||||||
|
class Recursive_const_flattening<0, InputIterator> {
|
||||||
|
public:
|
||||||
|
typedef Recursive_const_flattening Self;
|
||||||
|
static const int level = 0;
|
||||||
|
typedef InputIterator Input_iterator;
|
||||||
|
|
||||||
|
typedef Input_iterator Recursive_flattening_iterator;
|
||||||
|
|
||||||
|
struct Flatten {
|
||||||
|
typedef Recursive_flattening_iterator result_type;
|
||||||
|
typedef Input_iterator argument_type;
|
||||||
|
|
||||||
|
Recursive_flattening_iterator
|
||||||
|
operator () (Input_iterator end, Input_iterator it) {
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class InputIterator>
|
||||||
|
class Recursive_const_flattening<1, InputIterator> {
|
||||||
|
public:
|
||||||
|
typedef Recursive_const_flattening Self;
|
||||||
|
static const int level = 1;
|
||||||
|
typedef InputIterator Input_iterator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Nested_iterator_traits
|
||||||
|
{
|
||||||
|
typedef Input_iterator Base_iterator;
|
||||||
|
typedef typename std::iterator_traits<Input_iterator>::value_type::const_iterator
|
||||||
|
Iterator;
|
||||||
|
|
||||||
|
Iterator begin(Input_iterator it) const { return it->begin(); }
|
||||||
|
Iterator end (Input_iterator it) const { return it->end(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef CGAL::Nested_iterator< Input_iterator, Nested_iterator_traits >
|
||||||
|
Recursive_flattening_iterator;
|
||||||
|
|
||||||
|
struct Flatten {
|
||||||
|
typedef Recursive_flattening_iterator result_type;
|
||||||
|
typedef Input_iterator argument_type;
|
||||||
|
|
||||||
|
Recursive_flattening_iterator
|
||||||
|
operator () (Input_iterator end, Input_iterator it) {
|
||||||
|
return Recursive_flattening_iterator(end,it);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \ingroup LiS_Flattening_iterator
|
||||||
|
\brief Recursive application of \c LiS::Flattening_const_iterator
|
||||||
|
|
||||||
|
An instance \c LiS::Recursive_const_flattening<level,InputIterator>
|
||||||
|
of this class template contains a typedef \c Recursive_flattening_iterator.
|
||||||
|
This is a \c level -fold nested instance of
|
||||||
|
\c LiS::Flattening_const_iterator, where \c level can be any
|
||||||
|
non-negative integer. At each nesting level, begin and end
|
||||||
|
functors are supplied to \c LiS::Flattening_const_iterator
|
||||||
|
which assume that their arguments have a
|
||||||
|
\c const_iterator typedef and \c begin() and \c end()
|
||||||
|
member functions in the style of the STL.
|
||||||
|
|
||||||
|
The functor <tt>Flatten()(it)</tt> converts an \c InputIterator \c it
|
||||||
|
to a \c Recursive_flattening_iterator. Converting each endpoint
|
||||||
|
of an iterator range [first,beyond) yields an iterator range
|
||||||
|
in which \c level levels of packing into containers have been
|
||||||
|
unpacked. (In particular, the case \c level==0 is permissible
|
||||||
|
and a no-op.)
|
||||||
|
|
||||||
|
To get a \c const_iterator out of a container \c c of type \c C
|
||||||
|
which is not \c const itself, one can use syntax like
|
||||||
|
<tt>const_cast<const C&>(c).begin())</tt>. This may sometimes
|
||||||
|
be necessary in conjunction with \c LiS::Recursive_const_flattening.
|
||||||
|
*/
|
||||||
|
template< int level_, class InputIterator >
|
||||||
|
class Recursive_const_flattening {
|
||||||
|
public:
|
||||||
|
//! this instance itself
|
||||||
|
typedef Recursive_const_flattening Self;
|
||||||
|
//! this instance's first template argument
|
||||||
|
static const int level = level_;
|
||||||
|
//! this instance's second template argument
|
||||||
|
typedef InputIterator Input_iterator;
|
||||||
|
|
||||||
|
typedef Recursive_const_flattening<
|
||||||
|
level-1,
|
||||||
|
typename std::iterator_traits<Input_iterator>::value_type::const_iterator
|
||||||
|
> Nested_self;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Nested_iterator_traits
|
||||||
|
{
|
||||||
|
typedef Input_iterator
|
||||||
|
Base_iterator;
|
||||||
|
typedef typename Nested_self::Recursive_flattening_iterator
|
||||||
|
Iterator;
|
||||||
|
|
||||||
|
Iterator begin(Input_iterator it) const { return typename Nested_self::Flatten()(it->end(),it->begin()); }
|
||||||
|
Iterator end (Input_iterator it) const { return typename Nested_self::Flatten()(it->end(),it->end()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef CGAL::Nested_iterator< Input_iterator, Nested_iterator_traits >
|
||||||
|
Recursive_flattening_iterator;
|
||||||
|
|
||||||
|
//! conversion functor (model of STL concept \c AdaptableUnaryFunction )
|
||||||
|
struct Flatten {
|
||||||
|
//! result type
|
||||||
|
typedef Recursive_flattening_iterator result_type;
|
||||||
|
//! argument type
|
||||||
|
typedef Input_iterator argument_type;
|
||||||
|
|
||||||
|
//! conversion functor call
|
||||||
|
Recursive_flattening_iterator
|
||||||
|
operator () (Input_iterator end,Input_iterator it) {
|
||||||
|
return Recursive_flattening_iterator(end,it);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef DOXYGEN_RUNNING
|
||||||
|
/*! \ingroup LiS_Flattening_iterator
|
||||||
|
\brief (unimplemented)
|
||||||
|
|
||||||
|
This class template is unimplemented.
|
||||||
|
Only \c LiS::Recursive_const_flattening is available at this point.
|
||||||
|
*/
|
||||||
|
template <int level_, class InputIterator>
|
||||||
|
class Recursive_flattening { };
|
||||||
|
#endif // DOXYGEN_RUNNING
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Part 2: Helper functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \relates LiS::Recursive_const_flattening
|
||||||
|
* \brief map \c it to
|
||||||
|
* <tt>LiS::Recursive_const_flattening<level, InputIterator>::Flatten()(it)</tt>
|
||||||
|
*
|
||||||
|
* See \c LiS::Recursive_const_flattening for explanations.
|
||||||
|
* This function just exists to save typing via overloading resolution.
|
||||||
|
* You have to specify \c level explicitly in any case.
|
||||||
|
* For \c LiS::recursive_const_flattener<1,...>() , there is the
|
||||||
|
* shorthand \c LiS::const_flattener<...>() .
|
||||||
|
*/
|
||||||
|
template <int level, class InputIterator> inline
|
||||||
|
typename Recursive_const_flattening<level, InputIterator>
|
||||||
|
::Recursive_flattening_iterator
|
||||||
|
recursive_const_flattener(InputIterator end,InputIterator it) {
|
||||||
|
return typename Recursive_const_flattening<level, InputIterator>::Flatten()(end,it);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \relates LiS::Flattening_const_iterator
|
||||||
|
* \brief map \c it to
|
||||||
|
* <tt>LiS::Recursive_const_flattening<1, InputIterator>::Flatten()(it)</tt>
|
||||||
|
*
|
||||||
|
* A function call <tt>fi = const_flattener(it)</tt> converts the iterator
|
||||||
|
* \c it to an instance of \c LiS::Flattening_const_iterator (see ibid.).
|
||||||
|
* The template arguments are chosen as follows:
|
||||||
|
* - \c InputIterator1 is \c InputIterator
|
||||||
|
* - \c InputIterator2 is \c InputIterator::value_type::const_iterator
|
||||||
|
* - \c UnaryFunction1/2 are set to functors that call \c begin()
|
||||||
|
* and \c end() member functions.
|
||||||
|
*
|
||||||
|
* This function helps to save typing and to avoid manual specification
|
||||||
|
* of \c UnaryFunction1/2.
|
||||||
|
*/
|
||||||
|
template <class InputIterator> inline
|
||||||
|
typename Recursive_const_flattening<1, InputIterator>
|
||||||
|
::Recursive_flattening_iterator
|
||||||
|
const_flattener(InputIterator end,InputIterator it) {
|
||||||
|
return typename Recursive_const_flattening<1, InputIterator>::Flatten()(end,it);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DOXYGEN_RUNNING
|
||||||
|
/*! \relates LiS::Recursive_flattener
|
||||||
|
\brief (unimplemented)
|
||||||
|
|
||||||
|
This function template is unimplemented.
|
||||||
|
Only \c LiS::recursive_const_flattener is available at this point.
|
||||||
|
*/
|
||||||
|
template <int level, class InputIterator> inline
|
||||||
|
typename Recursive_flattening<level, InputIterator>
|
||||||
|
::Recursive_flattening_iterator
|
||||||
|
recursive_flattener(InputIterator it);
|
||||||
|
|
||||||
|
/*! \relates LiS::Flattening_iteratos
|
||||||
|
\brief (unimplemented)
|
||||||
|
|
||||||
|
This function template is unimplemented.
|
||||||
|
Only \c LiS::const_flattener is available at this point.
|
||||||
|
*/
|
||||||
|
template <class InputIterator> inline
|
||||||
|
typename Recursive_flattening<1, InputIterator>
|
||||||
|
::Recursive_flattening_iterator
|
||||||
|
flattener(InputIterator it);
|
||||||
|
#endif // DOXYGEN_RUNNING
|
||||||
|
|
||||||
|
|
||||||
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // LiS_FLATTENING_ITERATOR_H
|
||||||
|
// EOF
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -17,7 +17,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Michael Hoffmann <hoffmann@inf.ethz.ch>
|
// Author(s) : Michael Hoffmann <hoffmann@inf.ethz.ch>
|
||||||
// Lutz Kettner <kettner@mpi-sb.mpg.de>
|
// Lutz Kettner <kettner@mpi-sb.mpg.de>
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include <CGAL/copy_n.h>
|
#include <CGAL/copy_n.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
template <class ForwardIterator>
|
template <class ForwardIterator>
|
||||||
|
|
@ -63,6 +65,7 @@ min_max_element(ForwardIterator first, ForwardIterator last)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class ForwardIterator, class CompareMin, class CompareMax >
|
template < class ForwardIterator, class CompareMin, class CompareMax >
|
||||||
std::pair< ForwardIterator, ForwardIterator >
|
std::pair< ForwardIterator, ForwardIterator >
|
||||||
min_max_element(ForwardIterator first,
|
min_max_element(ForwardIterator first,
|
||||||
|
|
@ -81,6 +84,7 @@ min_max_element(ForwardIterator first,
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class ForwardIterator, class Predicate >
|
template < class ForwardIterator, class Predicate >
|
||||||
ForwardIterator
|
ForwardIterator
|
||||||
min_element_if(ForwardIterator first,
|
min_element_if(ForwardIterator first,
|
||||||
|
|
@ -94,6 +98,7 @@ min_element_if(ForwardIterator first,
|
||||||
result = first;
|
result = first;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class ForwardIterator, class Compare, class Predicate >
|
template < class ForwardIterator, class Compare, class Predicate >
|
||||||
ForwardIterator
|
ForwardIterator
|
||||||
min_element_if(ForwardIterator first,
|
min_element_if(ForwardIterator first,
|
||||||
|
|
@ -108,6 +113,7 @@ min_element_if(ForwardIterator first,
|
||||||
result = first;
|
result = first;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class ForwardIterator, class Predicate >
|
template < class ForwardIterator, class Predicate >
|
||||||
ForwardIterator
|
ForwardIterator
|
||||||
max_element_if(ForwardIterator first,
|
max_element_if(ForwardIterator first,
|
||||||
|
|
@ -121,6 +127,7 @@ max_element_if(ForwardIterator first,
|
||||||
result = first;
|
result = first;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class ForwardIterator, class Compare, class Predicate >
|
template < class ForwardIterator, class Compare, class Predicate >
|
||||||
ForwardIterator
|
ForwardIterator
|
||||||
max_element_if(ForwardIterator first,
|
max_element_if(ForwardIterator first,
|
||||||
|
|
@ -137,6 +144,74 @@ max_element_if(ForwardIterator first,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief lexicographic comparison of the two ranges using the \a cmp
|
||||||
|
function object.
|
||||||
|
|
||||||
|
Compares the two ranges \c [first1,last1) and \c [first2,last2)
|
||||||
|
lexicographically and returns one of the \c CGAL::Comparison_result enum
|
||||||
|
values respectively:
|
||||||
|
- \c CGAL::SMALLER
|
||||||
|
- \c CGAL::EQUAL
|
||||||
|
- \c CGAL::LARGER
|
||||||
|
|
||||||
|
\pre The \c value_type of \a InputIterator1 must be convertible
|
||||||
|
to the \c first_argument_type of \c BinaryFunction.
|
||||||
|
The \c value_type of \a InputIterator2 must be convertible
|
||||||
|
to the \c second_argument_type of \c BinaryFunction.
|
||||||
|
The \c result_type of \c BinaryFunction must be convertible to
|
||||||
|
\c CGAL::Comparison_result.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class InputIterator1, class InputIterator2, class BinaryFunction>
|
||||||
|
CGAL::Comparison_result
|
||||||
|
lexicographical_compare_three_valued( InputIterator1 first1, InputIterator1 last1,
|
||||||
|
InputIterator2 first2, InputIterator2 last2,
|
||||||
|
BinaryFunction cmp) {
|
||||||
|
while ( first1 != last1 && first2 != last2) {
|
||||||
|
CGAL::Comparison_result result = cmp( *first1, *first2);
|
||||||
|
if ( result != CGAL::EQUAL)
|
||||||
|
return result;
|
||||||
|
++first1;
|
||||||
|
++first2;
|
||||||
|
}
|
||||||
|
if ( first1 != last1)
|
||||||
|
return CGAL::LARGER;
|
||||||
|
if ( first2 != last2)
|
||||||
|
return CGAL::SMALLER;
|
||||||
|
return CGAL::EQUAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \brief output iterator range to a stream, with separators
|
||||||
|
|
||||||
|
The iterator range \c [first,beyond) is written
|
||||||
|
to \c os (obeying EXACUS I/O modes). Each element is bracketed by
|
||||||
|
\c pre and \c post (default: empty string). Adjacent values are
|
||||||
|
spearated by \c sep (default: ", ", i.e. comma space).
|
||||||
|
The stream \c os is returned in its new state after output.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
<PRE>
|
||||||
|
int a[] = {1, 2, 3};
|
||||||
|
output_range(std::cout, a, a+3, ":", "(", ")");
|
||||||
|
</PRE>
|
||||||
|
produces \c (1):(2):(3)
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
std::ostream& output_range(std::ostream& os,
|
||||||
|
InputIterator first, InputIterator beyond,
|
||||||
|
const char* sep = ", ", const char* pre = "", const char* post = ""
|
||||||
|
) {
|
||||||
|
InputIterator it = first;
|
||||||
|
if (it != beyond) {
|
||||||
|
os << pre << oformat(*it) << post;
|
||||||
|
while (++it != beyond) os << sep << pre << oformat(*it) << post;
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_ALGORITHM_H //
|
#endif // CGAL_ALGORITHM_H //
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Geert-Jan Giezeman and Sven Schoenherr
|
// Author(s) : Geert-Jan Giezeman and Sven Schoenherr
|
||||||
|
|
||||||
|
|
@ -295,6 +295,8 @@ void warning_fail( const char*, const char*, int, const char*);
|
||||||
# define CGAL_expensive_exactness_warning_code(CODE) CODE
|
# define CGAL_expensive_exactness_warning_code(CODE) CODE
|
||||||
#endif // CGAL_KERNEL_NO_WARNINGS
|
#endif // CGAL_KERNEL_NO_WARNINGS
|
||||||
|
|
||||||
|
// CGAL error
|
||||||
|
#define CGAL_error(MSG) ::CGAL::assertion_fail( "", __FILE__, __LINE__, MSG )
|
||||||
|
|
||||||
// failure handler declarations
|
// failure handler declarations
|
||||||
// ==========================
|
// ==========================
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ struct Tag_false {};
|
||||||
inline bool check_tag( Tag_true) {return true;}
|
inline bool check_tag( Tag_true) {return true;}
|
||||||
inline bool check_tag( Tag_false) {return false;}
|
inline bool check_tag( Tag_false) {return false;}
|
||||||
|
|
||||||
|
struct Null_tag {};
|
||||||
|
struct Null_functor {};
|
||||||
|
|
||||||
|
|
||||||
// A function that asserts a specific compile time tag
|
// A function that asserts a specific compile time tag
|
||||||
// forcing its two arguments to have equal type.
|
// forcing its two arguments to have equal type.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : Support
|
||||||
|
// File : test/Cache.C
|
||||||
|
// SoX_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Michael Hemmer <hemmer@informatik.uni-mainz.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
#include <CGAL/Cache.h>
|
||||||
|
#include <CGAL/Handle_with_policy.h>
|
||||||
|
#include <CGAL/function_objects.h>
|
||||||
|
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/type_traits.hpp>
|
||||||
|
|
||||||
|
struct Int_rep {
|
||||||
|
int val;
|
||||||
|
Int_rep( int i = 0) : val(i) {}
|
||||||
|
Int_rep( int i, int j) : val(i+j) {}
|
||||||
|
Int_rep( int i, int j, int k) : val(i+j+k) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class Unify>
|
||||||
|
struct Int_t : public CGAL::Handle_with_policy< Int_rep, Unify > {
|
||||||
|
typedef CGAL::Handle_with_policy< Int_rep, Unify > Base;
|
||||||
|
Int_t( int i = 0) : Base( i) {}
|
||||||
|
Int_t( int i, int j) : Base( i, j) {} // test template constructors
|
||||||
|
Int_t( int i, int j, int k) : Base( Base::USE_WITH_INITIALIZE_WITH) {
|
||||||
|
// test initialize_with
|
||||||
|
this->initialize_with( i, j + k);
|
||||||
|
}
|
||||||
|
int value() const { return this->ptr()->val; }
|
||||||
|
void set_value( int i) {
|
||||||
|
this->copy_on_write();
|
||||||
|
this->ptr()->val = i;
|
||||||
|
}
|
||||||
|
bool operator==( const Int_t<Unify>& i) const {
|
||||||
|
bool equal = (value() == i.value());
|
||||||
|
if ( equal)
|
||||||
|
unify(i);
|
||||||
|
return equal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test_typedefs(){
|
||||||
|
typedef CGAL::Cache<int,double> Cache;
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same< Cache::Input, int >::value ));
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same< Cache::Output,double>::value ));
|
||||||
|
typedef CGAL::Creator_1<int,double> Creator_double;
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same<Cache::Creator,Creator_double>::value ));
|
||||||
|
typedef CGAL::Creator_1<int,int> Creator_int;
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same<Cache::Canonicalizer,Creator_int>::value ));
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same<Cache::Compare,std::less<int> >::value ));
|
||||||
|
BOOST_STATIC_ASSERT(( ::boost::is_same<Cache::Self,CGAL::Cache<int,double> >::value ));
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
{
|
||||||
|
test_typedefs();
|
||||||
|
{
|
||||||
|
typedef CGAL::Cache<int,double> Cache;
|
||||||
|
double d;
|
||||||
|
Cache cache;
|
||||||
|
CGAL_test_assert(cache.is_empty());
|
||||||
|
CGAL_test_assert(cache.size()==0);
|
||||||
|
d=cache(3);
|
||||||
|
CGAL_test_assert(d==double(3));
|
||||||
|
CGAL_test_assert(cache.size()==1);
|
||||||
|
d=cache(4);
|
||||||
|
CGAL_test_assert(d==double(4));
|
||||||
|
CGAL_test_assert(cache.size()==2);
|
||||||
|
d=cache(3);
|
||||||
|
CGAL_test_assert(d==double(3));
|
||||||
|
CGAL_test_assert(cache.size()==2);
|
||||||
|
d=cache(2);
|
||||||
|
CGAL_test_assert(d==double(2));
|
||||||
|
CGAL_test_assert(cache.size()==3);
|
||||||
|
|
||||||
|
typedef Cache::Iterator Iterator;
|
||||||
|
typedef Cache::Const_iterator Const_iterator;
|
||||||
|
typedef Cache::Reverse_iterator Reverse_iterator;
|
||||||
|
typedef Cache::Const_reverse_iterator Const_reverse_iterator;
|
||||||
|
typedef Cache::Size_type Size_type;
|
||||||
|
|
||||||
|
Iterator it;
|
||||||
|
d=0;
|
||||||
|
for(it=cache.begin();it!=cache.end();it++){
|
||||||
|
CGAL_test_assert(d<(*it).second);
|
||||||
|
d=(*it).second;
|
||||||
|
}
|
||||||
|
cache.clear();
|
||||||
|
CGAL_test_assert(cache.size()==0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< CGAL::Handle_policy_no_union > Int;
|
||||||
|
typedef CGAL::Cache<int,Int> Cache;
|
||||||
|
Int hi,hi2;
|
||||||
|
Cache cache;
|
||||||
|
CGAL_test_assert(cache.is_empty());
|
||||||
|
CGAL_test_assert(cache.size()==0);
|
||||||
|
hi=cache(3);
|
||||||
|
CGAL_test_assert(hi==Int(3));
|
||||||
|
CGAL_test_assert(cache.size()==1);
|
||||||
|
hi2=cache(4);
|
||||||
|
CGAL_test_assert(hi2==Int(4));
|
||||||
|
CGAL_test_assert(cache.size()==2);
|
||||||
|
hi2=cache(3);
|
||||||
|
CGAL_test_assert(hi.id()==hi2.id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : LiS
|
||||||
|
// File : test/Flattening_iterator.C
|
||||||
|
// LiS_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Arno Eigenwillig <arno@mpi-inf.mpg.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#include <CGAL/Flattening_iterator.h>
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
void test_const_flattening() {
|
||||||
|
typedef std::vector<int> V1;
|
||||||
|
typedef std::vector<V1> V2;
|
||||||
|
typedef std::vector<V2> V3;
|
||||||
|
|
||||||
|
V1 a1, a2, a3, a4, a5, a6;
|
||||||
|
|
||||||
|
a1.push_back(1); a1.push_back(2); a1.push_back(3); a1.push_back(4);
|
||||||
|
a2.push_back(5); a2.push_back(6); a2.push_back(7);
|
||||||
|
a3.push_back(8);
|
||||||
|
a4.push_back(9); a4.push_back(10); a4.push_back(11); a4.push_back(12);
|
||||||
|
a5.push_back(13); a5.push_back(14);
|
||||||
|
a6.push_back(15); a6.push_back(16); a6.push_back(17);
|
||||||
|
|
||||||
|
V2 b1, b2, b3;
|
||||||
|
|
||||||
|
b1.push_back(a1); b1.push_back(a2);
|
||||||
|
b2.push_back(a3);
|
||||||
|
b3.push_back(a4); b3.push_back(a5); b3.push_back(a6);
|
||||||
|
|
||||||
|
V3 c;
|
||||||
|
c.push_back(b1); c.push_back(b2); c.push_back(b3);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
|
CGAL::Recursive_const_flattening<0, V1::const_iterator>
|
||||||
|
::Recursive_flattening_iterator fi10, fi10_beyond;
|
||||||
|
fi10 = CGAL::recursive_const_flattener<0>( a1.end(),a1.begin() );
|
||||||
|
fi10_beyond = CGAL::recursive_const_flattener<0>( a1.end(),a1.end() );
|
||||||
|
for (i = 1; i <= 4; ++i, ++fi10) {
|
||||||
|
CGAL_test_assert(*fi10 == i);
|
||||||
|
}
|
||||||
|
CGAL_test_assert(fi10 == fi10_beyond);
|
||||||
|
|
||||||
|
CGAL::Recursive_const_flattening<1, V2::const_iterator>
|
||||||
|
::Recursive_flattening_iterator fi21, fi21_beyond;
|
||||||
|
fi21= CGAL::recursive_const_flattener<1>(const_cast<const V2&>(b1).end(), const_cast<const V2&>(b1).begin());
|
||||||
|
fi21_beyond = CGAL::const_flattener(const_cast<const V2&>(b1).end(), const_cast<const V2&>(b1).end());
|
||||||
|
for (i = 1; i <= 7; ++i, ++fi21) {
|
||||||
|
CGAL_test_assert(*fi21 == i);
|
||||||
|
}
|
||||||
|
CGAL_test_assert(fi21 == fi21_beyond);
|
||||||
|
|
||||||
|
CGAL::Recursive_const_flattening<2, V3::iterator>
|
||||||
|
::Recursive_flattening_iterator fi32, fi32_beyond;
|
||||||
|
fi32 = CGAL::recursive_const_flattener<2>(c.end(),c.begin());
|
||||||
|
fi32_beyond = CGAL::recursive_const_flattener<2>(c.end(),c.end());
|
||||||
|
for (i = 1; i <= 17; ++i, ++fi32) {
|
||||||
|
CGAL_test_assert(*fi32 == i);
|
||||||
|
}
|
||||||
|
CGAL_test_assert(fi32 == fi32_beyond);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
test_const_flattening();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
||||||
|
|
@ -0,0 +1,501 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : LiS
|
||||||
|
// File : test/Handle.C
|
||||||
|
// LiS_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Michael Seel <seel@mpi-inf.mpg.de>
|
||||||
|
// Arno Eigenwillig <arno@mpi-inf.mpg.de>
|
||||||
|
// Lutz Kettner <kettner@mpi-inf.mpg.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#define HANDLE_WITH_POLICY_TEST
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/memory.h>
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
|
||||||
|
#include <CGAL/LiS/basic.h>
|
||||||
|
#include <CGAL/Handle_with_policy.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
struct Int_rep {
|
||||||
|
int val;
|
||||||
|
Int_rep( int i = 0) : val(i) {}
|
||||||
|
Int_rep( int i, int j) : val(i+j) {}
|
||||||
|
Int_rep( int i, int j, int k) : val(i+j+k) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class Unify>
|
||||||
|
struct Int_t : public ::CGAL::Handle_with_policy< Int_rep, Unify > {
|
||||||
|
typedef ::CGAL::Handle_with_policy< Int_rep, Unify > Base;
|
||||||
|
Int_t( int i = 0) : Base( i) {}
|
||||||
|
Int_t( int i, int j) : Base( i, j) {} // test template constructors
|
||||||
|
Int_t( int i, int j, int k) : Base( Base::USE_WITH_INITIALIZE_WITH) {
|
||||||
|
// test initialize_with
|
||||||
|
this->initialize_with( i, j + k);
|
||||||
|
}
|
||||||
|
int value() const { return this->ptr()->val; }
|
||||||
|
void set_value( int i) {
|
||||||
|
this->copy_on_write();
|
||||||
|
this->ptr()->val = i;
|
||||||
|
}
|
||||||
|
bool operator==( const Int_t<Unify>& i) const {
|
||||||
|
bool equal = (value() == i.value());
|
||||||
|
if ( equal)
|
||||||
|
unify(i);
|
||||||
|
return equal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test_handle() {
|
||||||
|
{ // test template constructor and initialize_with
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_no_union> Int;
|
||||||
|
Int i(5,6);
|
||||||
|
CGAL_test_assert( i == Int(11));
|
||||||
|
Int j(5,6,7);
|
||||||
|
CGAL_test_assert( j == Int(18));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_in_place> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_no_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( (std::ptrdiff_t)(ID_Number(i)) == i.id() );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_union_and_reset> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_t< ::CGAL::Handle_policy_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(5);
|
||||||
|
Int l(5);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// pump up the union_size counter for j, k and l
|
||||||
|
Int j1(j);
|
||||||
|
CGAL_test_assert( j1.test_identical_ptr( j));
|
||||||
|
Int k1(k);
|
||||||
|
Int k2(k);
|
||||||
|
Int k3(k);
|
||||||
|
Int l1(l);
|
||||||
|
Int l2(l);
|
||||||
|
Int l3(l);
|
||||||
|
Int l4(l);
|
||||||
|
Int l5(l);
|
||||||
|
Int l6(l);
|
||||||
|
Int l7(l);
|
||||||
|
Int l8(l);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 2);
|
||||||
|
CGAL_test_assert( j.union_size() == 3);
|
||||||
|
CGAL_test_assert( k.union_size() == 5);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link i to j
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 4);
|
||||||
|
CGAL_test_assert( j.union_size() == 4);
|
||||||
|
CGAL_test_assert( k.union_size() == 5);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j1));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link j to k
|
||||||
|
CGAL_test_assert( j == k);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 9);
|
||||||
|
CGAL_test_assert( k.union_size() == 9);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link k to l
|
||||||
|
CGAL_test_assert( k == l);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 8);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
// find j, links it to k and l
|
||||||
|
CGAL_test_assert( j.value() == 5);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 19);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
// find i, links it to j, k and l
|
||||||
|
CGAL_test_assert( i.value() == 5);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 19);
|
||||||
|
CGAL_test_assert( j.union_size() == 19);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fully generic example to show, how allocator and policy can be transported
|
||||||
|
// from the templated handle to the templated rep. For hard-coded choices
|
||||||
|
// one could derive directly from one of the following base classes:
|
||||||
|
// -- struct Int_vrep : public ::CGAL::Reference_counted_hierarchy_with_union<>
|
||||||
|
// -- struct Int_vrep : public ::CGAL::Reference_counted_hierarchy<>
|
||||||
|
|
||||||
|
template <class Policy, class Alloc>
|
||||||
|
struct Int_vrep : public Policy::template Hierarchy_base< Alloc>::Type {
|
||||||
|
int val;
|
||||||
|
virtual CGAL::Reference_counted_hierarchy<Alloc>* clone() {
|
||||||
|
return new Int_vrep( *this);
|
||||||
|
}
|
||||||
|
virtual int get_val() const { return val; }
|
||||||
|
virtual void set_val( int i) { val = i; }
|
||||||
|
Int_vrep( int i = 0) : val(i) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Policy, class Alloc>
|
||||||
|
struct Int_vrep2 : public Int_vrep<Policy,Alloc> {
|
||||||
|
int val2;
|
||||||
|
virtual ::CGAL::Reference_counted_hierarchy<Alloc>* clone() {
|
||||||
|
return new Int_vrep2( *this);
|
||||||
|
}
|
||||||
|
virtual int get_val() const { return this->val + val2; }
|
||||||
|
virtual void set_val( int i) { this->val = i - val2; }
|
||||||
|
Int_vrep2( int i, int j) : Int_vrep<Policy,Alloc>(i), val2(j) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Policy, class Alloc>
|
||||||
|
struct Int_vrep3 : public Int_vrep2<Policy,Alloc> {
|
||||||
|
int val3;
|
||||||
|
virtual ::CGAL::Reference_counted_hierarchy<Alloc>* clone() {
|
||||||
|
return new Int_vrep3( *this);
|
||||||
|
}
|
||||||
|
virtual int get_val() const { return this->val + this->val2 + val3; }
|
||||||
|
virtual void set_val( int i) { this->val = i - this->val2 - val3; }
|
||||||
|
Int_vrep3( int i, int j, int k) : Int_vrep2<Policy,Alloc>(i,j), val3(k) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class Unify, class Alloc = CGAL_ALLOCATOR(char) >
|
||||||
|
struct Int_vt : public ::CGAL::Handle_with_policy< Int_vrep<Unify,Alloc>, Unify > {
|
||||||
|
typedef ::CGAL::Handle_with_policy< Int_vrep<Unify,Alloc>, Unify > Base;
|
||||||
|
Int_vt( int i = 0) : Base( new Int_vrep<Unify,Alloc>(i)) {}
|
||||||
|
Int_vt( int i, int j) : Base( new Int_vrep2<Unify,Alloc>(i,j)) {}
|
||||||
|
Int_vt( int i, int j, int k) : Base( new Int_vrep3<Unify,Alloc>(i,j,k)) {}
|
||||||
|
|
||||||
|
int value() const { return this->ptr()->get_val(); }
|
||||||
|
void set_value( int i) {
|
||||||
|
this->copy_on_write();
|
||||||
|
this->ptr()->set_val(i);
|
||||||
|
}
|
||||||
|
bool operator==( const Int_vt<Unify>& i) const {
|
||||||
|
bool equal = (value() == i.value());
|
||||||
|
if ( equal)
|
||||||
|
unify(i);
|
||||||
|
return equal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void test_handle_with_class_hierarchy() {
|
||||||
|
{ // test template constructor and initialize_with
|
||||||
|
typedef Int_vt< ::CGAL::Handle_policy_no_union> Int;
|
||||||
|
Int i(5,6);
|
||||||
|
CGAL_test_assert( i == Int(11));
|
||||||
|
Int j(5,6,7);
|
||||||
|
CGAL_test_assert( j == Int(18));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
//typedef Int_vt< ::CGAL::Handle_policy_in_place> Int; // That's supposed to fail
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_vt< ::CGAL::Handle_policy_no_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( (std::ptrdiff_t)(ID_Number(i)) == i.id() );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_vt< ::CGAL::Handle_policy_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_vt< ::CGAL::Handle_policy_union_and_reset> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(6);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! (i == k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef Int_vt< ::CGAL::Handle_policy_union> Int;
|
||||||
|
Int i(5);
|
||||||
|
Int j(5);
|
||||||
|
Int k(5);
|
||||||
|
Int l(5);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// pump up the union_size counter for j, k and l
|
||||||
|
Int j1(j);
|
||||||
|
CGAL_test_assert( j1.test_identical_ptr( j));
|
||||||
|
Int k1(k);
|
||||||
|
Int k2(k);
|
||||||
|
Int k3(k);
|
||||||
|
Int l1(l);
|
||||||
|
Int l2(l);
|
||||||
|
Int l3(l);
|
||||||
|
Int l4(l);
|
||||||
|
Int l5(l);
|
||||||
|
Int l6(l);
|
||||||
|
Int l7(l);
|
||||||
|
Int l8(l);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 2);
|
||||||
|
CGAL_test_assert( j.union_size() == 3);
|
||||||
|
CGAL_test_assert( k.union_size() == 5);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link i to j
|
||||||
|
CGAL_test_assert( i == j);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 4);
|
||||||
|
CGAL_test_assert( j.union_size() == 4);
|
||||||
|
CGAL_test_assert( k.union_size() == 5);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j1));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link j to k
|
||||||
|
CGAL_test_assert( j == k);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 9);
|
||||||
|
CGAL_test_assert( k.union_size() == 9);
|
||||||
|
CGAL_test_assert( l.union_size() == 10);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! k.test_identical_ptr( l));
|
||||||
|
// link k to l
|
||||||
|
CGAL_test_assert( k == l);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 8);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
// find j, links it to k and l
|
||||||
|
CGAL_test_assert( j.value() == 5);
|
||||||
|
CGAL_test_assert( i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 3);
|
||||||
|
CGAL_test_assert( j.union_size() == 19);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( ! i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
// find i, links it to j, k and l
|
||||||
|
CGAL_test_assert( i.value() == 5);
|
||||||
|
CGAL_test_assert( ! i.is_forwarding());
|
||||||
|
CGAL_test_assert( ! j.is_forwarding());
|
||||||
|
CGAL_test_assert( ! k.is_forwarding());
|
||||||
|
CGAL_test_assert( ! l.is_forwarding());
|
||||||
|
CGAL_test_assert( i.union_size() == 19);
|
||||||
|
CGAL_test_assert( j.union_size() == 19);
|
||||||
|
CGAL_test_assert( k.union_size() == 19);
|
||||||
|
CGAL_test_assert( l.union_size() == 19);
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( j));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( i.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( k));
|
||||||
|
CGAL_test_assert( j.test_identical_ptr( l));
|
||||||
|
CGAL_test_assert( k.test_identical_ptr( l));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
test_handle();
|
||||||
|
test_handle_with_class_hierarchy();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : LiS
|
||||||
|
// File : test/algorithm_test.C
|
||||||
|
// LiS_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-inf.mpg.de>
|
||||||
|
// Arno Eigenwillig <arno@mpi-inf.mpg.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
#include <CGAL/algorithm.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
int A[] = {1,2,3,4,5};
|
||||||
|
|
||||||
|
int B1[] = {1,1,3};
|
||||||
|
int B2[] = {1,2,3};
|
||||||
|
|
||||||
|
CGAL::Comparison_result compare( int i, int j) {
|
||||||
|
if ( i<j)
|
||||||
|
return CGAL::SMALLER;
|
||||||
|
if ( i>j)
|
||||||
|
return CGAL::LARGER;
|
||||||
|
return CGAL::EQUAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_lex_compare() {
|
||||||
|
CGAL_test_assert( CGAL::EQUAL == CGAL::lexicographical_compare_three_valued( A, A+3, A, A+3, compare));
|
||||||
|
CGAL_test_assert( CGAL::SMALLER == CGAL::lexicographical_compare_three_valued( A, A+3, A, A+4, compare));
|
||||||
|
CGAL_test_assert( CGAL::SMALLER == CGAL::lexicographical_compare_three_valued( A, A+3, A, A+5, compare));
|
||||||
|
CGAL_test_assert( CGAL::LARGER == CGAL::lexicographical_compare_three_valued( A, A+4, A, A+3, compare));
|
||||||
|
CGAL_test_assert( CGAL::LARGER == CGAL::lexicographical_compare_three_valued( A, A+5, A, A+3, compare));
|
||||||
|
|
||||||
|
CGAL_test_assert( CGAL::SMALLER == CGAL::lexicographical_compare_three_valued( B1, B1+3, B2, B2+3, compare));
|
||||||
|
CGAL_test_assert( CGAL::LARGER == CGAL::lexicographical_compare_three_valued( B2, B2+3, B1, B1+3, compare));
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_output_range() {
|
||||||
|
std::ostringstream os;
|
||||||
|
std::ostream* sp;
|
||||||
|
CGAL::set_ascii_mode(os);
|
||||||
|
|
||||||
|
CGAL_test_assert(os.str() == "");
|
||||||
|
|
||||||
|
sp = &(CGAL::output_range(os, A, A, ":", "(", ")"));
|
||||||
|
CGAL_test_assert(os.str() == "");
|
||||||
|
CGAL_test_assert(sp == &os);
|
||||||
|
os.str("");
|
||||||
|
|
||||||
|
sp = &(CGAL::output_range(os, A, A+1, ":", "(", ")"));
|
||||||
|
CGAL_test_assert(os.str() == "(1)");
|
||||||
|
CGAL_test_assert(sp == &os);
|
||||||
|
os.str("");
|
||||||
|
|
||||||
|
sp = &(CGAL::output_range(os, A, A+3, ":", "(", ")"));
|
||||||
|
CGAL_test_assert(os.str() == "(1):(2):(3)");
|
||||||
|
CGAL_test_assert(sp == &os);
|
||||||
|
os.str("");
|
||||||
|
|
||||||
|
sp = &(CGAL::output_range(os, A, A+3));
|
||||||
|
CGAL_test_assert(os.str() == "1, 2, 3");
|
||||||
|
CGAL_test_assert(sp == &os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
test_lex_compare();
|
||||||
|
test_output_range();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
||||||
|
|
@ -28,4 +28,7 @@
|
||||||
#define CGAL_test_assert(EX) \
|
#define CGAL_test_assert(EX) \
|
||||||
((EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, 0))
|
((EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, 0))
|
||||||
|
|
||||||
|
#define CGAL_test_assert_msg(EX,MSG) \
|
||||||
|
((EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
|
||||||
|
|
||||||
#endif // CGAL_TESTSUITE_ASSERT_H
|
#endif // CGAL_TESTSUITE_ASSERT_H
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Andreas Fabri
|
// Author(s) : Andreas Fabri
|
||||||
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#define CGAL_IO_H
|
#define CGAL_IO_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <CGAL/tags.h>
|
||||||
#include <CGAL/IO/io_tags.h>
|
#include <CGAL/IO/io_tags.h>
|
||||||
#include <CGAL/IO/Color.h>
|
#include <CGAL/IO/Color.h>
|
||||||
|
|
||||||
|
|
@ -35,9 +36,71 @@ CGAL_BEGIN_NAMESPACE
|
||||||
class IO {
|
class IO {
|
||||||
public:
|
public:
|
||||||
static int mode;
|
static int mode;
|
||||||
enum Mode {ASCII = 0, PRETTY, BINARY};
|
enum Mode {ASCII = 0, PRETTY, BENCHMARK, BINARY};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T, class F = ::CGAL::Null_tag >
|
||||||
|
class Output_rep {
|
||||||
|
const T& t;
|
||||||
|
public:
|
||||||
|
//! initialize with a const reference to \a t.
|
||||||
|
Output_rep( const T& tt) : t(tt) {}
|
||||||
|
//! perform the output, calls \c operator\<\< by default.
|
||||||
|
std::ostream& operator()( std::ostream& out) const { return (out << t); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \relates Output_rep
|
||||||
|
\brief stream output of the \c Output_rep calls its \c operator().
|
||||||
|
*/
|
||||||
|
template <class T, class F>
|
||||||
|
std::ostream&
|
||||||
|
operator<<( std::ostream& out, Output_rep<T,F> rep) {
|
||||||
|
return rep( out);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! generic IO output format manipulator.
|
||||||
|
template <class T>
|
||||||
|
Output_rep<T>
|
||||||
|
oformat( const T& t) { return Output_rep<T>(t); }
|
||||||
|
|
||||||
|
//! generic IO output format manipulator with formatting tag.
|
||||||
|
template <class T, class F>
|
||||||
|
Output_rep<T,F>
|
||||||
|
oformat( const T& t, F) { return Output_rep<T,F>(t); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!\brief
|
||||||
|
* input functor class created by the generic IO input manipulator.
|
||||||
|
*
|
||||||
|
* It holds a reference to the input object. Default implementation
|
||||||
|
* calls the stream input operator. Specializations can be written
|
||||||
|
* for external types not supporting our stream IO format.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
class Input_rep {
|
||||||
|
T& t;
|
||||||
|
public:
|
||||||
|
//! initialize with a reference to \a t.
|
||||||
|
Input_rep( T& tt) : t(tt) {}
|
||||||
|
//! perform the input, calls \c operator\>\> by default.
|
||||||
|
std::istream& operator()( std::istream& in) const { return (in >> t); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! \relates Input_rep
|
||||||
|
\brief stream input to the \c Input_rep calls its \c operator().
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
std::istream&
|
||||||
|
operator>>( std::istream& in, Input_rep<T> rep) {
|
||||||
|
return rep( in);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! generic IO input format manipulator.
|
||||||
|
template <class T>
|
||||||
|
Input_rep<T>
|
||||||
|
iformat( T& t) { return Input_rep<T>(t); }
|
||||||
|
|
||||||
IO::Mode
|
IO::Mode
|
||||||
get_mode(std::ios& i);
|
get_mode(std::ios& i);
|
||||||
|
|
||||||
|
|
@ -50,8 +113,12 @@ set_binary_mode(std::ios& i);
|
||||||
IO::Mode
|
IO::Mode
|
||||||
set_pretty_mode(std::ios& i);
|
set_pretty_mode(std::ios& i);
|
||||||
|
|
||||||
|
IO::Mode
|
||||||
|
set_benchmark_mode(std::ios& i);
|
||||||
|
|
||||||
IO::Mode
|
IO::Mode
|
||||||
set_mode(std::ios& i, IO::Mode m);
|
set_mode(std::ios& i, IO::Mode m);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_pretty(std::ios& i);
|
is_pretty(std::ios& i);
|
||||||
|
|
||||||
|
|
@ -61,6 +128,9 @@ is_ascii(std::ios& i);
|
||||||
bool
|
bool
|
||||||
is_binary(std::ios& i);
|
is_binary(std::ios& i);
|
||||||
|
|
||||||
|
bool
|
||||||
|
is_benchmark(std::ios& i);
|
||||||
|
|
||||||
inline io_Read_write io_tag(char){ return io_Read_write(); }
|
inline io_Read_write io_tag(char){ return io_Read_write(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -78,7 +148,7 @@ inline
|
||||||
void
|
void
|
||||||
write(std::ostream& os, const T& t, const io_Operator&)
|
write(std::ostream& os, const T& t, const io_Operator&)
|
||||||
{
|
{
|
||||||
os << t;
|
os << oformat(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -114,7 +184,7 @@ inline
|
||||||
void
|
void
|
||||||
read(std::istream& is, T& t, const io_Operator&)
|
read(std::istream& is, T& t, const io_Operator&)
|
||||||
{
|
{
|
||||||
is >> t;
|
is >> iformat(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -141,8 +211,8 @@ std::ostream& operator<<( std::ostream& out, const Color& col)
|
||||||
{
|
{
|
||||||
switch(out.iword(IO::mode)) {
|
switch(out.iword(IO::mode)) {
|
||||||
case IO::ASCII :
|
case IO::ASCII :
|
||||||
return out << static_cast<int>(col.red()) << ' '
|
return out << static_cast<int>(col.red()) << ' '
|
||||||
<< static_cast<int>(col.green()) << ' '
|
<< static_cast<int>(col.green()) << ' '
|
||||||
<< static_cast<int>(col.blue());
|
<< static_cast<int>(col.blue());
|
||||||
case IO::BINARY :
|
case IO::BINARY :
|
||||||
write(out, static_cast<int>(col.red()));
|
write(out, static_cast<int>(col.red()));
|
||||||
|
|
@ -150,7 +220,7 @@ std::ostream& operator<<( std::ostream& out, const Color& col)
|
||||||
write(out, static_cast<int>(col.blue()));
|
write(out, static_cast<int>(col.blue()));
|
||||||
return out;
|
return out;
|
||||||
default:
|
default:
|
||||||
return out << "Color(" << static_cast<int>(col.red()) << ", "
|
return out << "Color(" << static_cast<int>(col.red()) << ", "
|
||||||
<< static_cast<int>(col.green()) << ", "
|
<< static_cast<int>(col.green()) << ", "
|
||||||
<< static_cast<int>(col.blue()) << ')';
|
<< static_cast<int>(col.blue()) << ')';
|
||||||
}
|
}
|
||||||
|
|
@ -178,6 +248,9 @@ std::istream &operator>>(std::istream &is, Color& col)
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* mode_name( IO::Mode m );
|
||||||
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_IO_H
|
#endif // CGAL_IO_H
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
#include <CGAL/IO/io.h>
|
#include <CGAL/IO/io.h>
|
||||||
|
#include <CGAL/assertions.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -65,6 +66,12 @@ set_pretty_mode(std::ios& i)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IO::Mode
|
||||||
|
set_benchmark_mode(std::ios& i)
|
||||||
|
{
|
||||||
|
set_mode( i, IO::BENCHMARK );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
IO::Mode
|
IO::Mode
|
||||||
set_mode(std::ios& i, IO::Mode m)
|
set_mode(std::ios& i, IO::Mode m)
|
||||||
|
|
@ -93,6 +100,19 @@ is_binary(std::ios& i)
|
||||||
return i.iword(IO::mode) == IO::BINARY;
|
return i.iword(IO::mode) == IO::BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
is_benchmark(std::ios& i)
|
||||||
|
{
|
||||||
|
return i.iword(IO::mode) == IO::BENCHMARK;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* mode_name( IO::Mode m) {
|
||||||
|
static const char* const names[] = {"ASCII", "PRETTY", "BENCHMARK", "BINARY" };
|
||||||
|
CGAL_assertion( IO::ASCII <= m && m <= IO::BINARY );
|
||||||
|
return names[m];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_IO_C
|
#endif // CGAL_IO_C
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
42
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
// ============================================================================
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2006 Max-Planck-Institut Saarbruecken (Germany).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of EXACUS (http://www.mpi-inf.mpg.de/projects/EXACUS/);
|
||||||
|
// you may redistribute it under the terms of the Q Public License version 1.0.
|
||||||
|
// See the file LICENSE.QPL distributed with EXACUS.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
|
//
|
||||||
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Library : LiS
|
||||||
|
// File : test/io.C
|
||||||
|
// LiS_release : $Name: $
|
||||||
|
// Revision : $Revision$
|
||||||
|
// Revision_date : $Date$
|
||||||
|
//
|
||||||
|
// Author(s) : Lutz Kettner <kettner@mpi-inf.mpg.de>
|
||||||
|
//
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/IO/io.h>
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << CGAL::oformat(5) << std::endl;
|
||||||
|
std::cout << CGAL::oformat("Ok") << std::endl;
|
||||||
|
int i;
|
||||||
|
std::cin >> CGAL::iformat(i);
|
||||||
|
CGAL_test_assert( i == 42);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue