From d8aa7d7422945ec35f7edf4fdf3737d3168cf248 Mon Sep 17 00:00:00 2001 From: Mariette Yvinec Date: Tue, 28 May 2002 13:53:07 +0000 Subject: [PATCH] input from Sylvain --- .../include/CGAL/Trivial_iterator.h | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 Packages/Triangulation_2/include/CGAL/Trivial_iterator.h diff --git a/Packages/Triangulation_2/include/CGAL/Trivial_iterator.h b/Packages/Triangulation_2/include/CGAL/Trivial_iterator.h new file mode 100644 index 00000000000..5bfbbb8c532 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Trivial_iterator.h @@ -0,0 +1,180 @@ +// ====================================================================== +// +// Copyright (c) 2002 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/Trivial_iterator.h +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Sylvain Pion +// +// coordinator : Mariette Yvinec +// +// ====================================================================== + +#ifndef CGAL_TRIVIAL_ITERATOR_H +#define CGAL_TRIVIAL_ITERATOR_H + +#include +#include + +CGAL_BEGIN_NAMESPACE + +// TODO : +// - iterator_category should not be exactly forwarded... +// - comparison operators should be global. +// - Have a look at Boost's concept_checking and archetypes : +// http://www.boost.org/libs/concept_check/concept_check.htm + +#if defined(CGAL_CFG_NO_ITERATOR_TRAITS) && \ +!defined(CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT) +template < class I, class Ref, class Ptr, + class Val, class Dist, class Ctg > +#elif !defined __SUNPRO_CC +template < class I, + class Ref = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::reference, + class Ptr = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::pointer, + class Val = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::value_type, + class Dist = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::difference_type, + class Ctg = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::iterator_category> +#else +template < class I, + class Ref = typename CGALi::IT_rename::REF, + class Ptr = typename CGALi::IT_rename::PTR, + class Val = typename CGALi::IT_rename::VAL, + class Dist = typename CGALi::IT_rename::DIF, + class Ctg = typename CGALi::IT_rename::CAT > +#endif +class Trivial_iterator +{ +public: + typedef I Iterator; + typedef Trivial_iterator Self; + typedef Ctg iterator_category; + typedef Val value_type; + typedef Dist difference_type; +#ifdef CGAL_CFG_NO_ITERATOR_TRAITS + typedef Ref reference; + typedef Ptr pointer; +#else + typedef typename std::iterator_traits::reference reference; + typedef typename std::iterator_traits::pointer pointer; +#endif + // Special for circulators. + typedef I_Circulator_size_traits C_S_Traits; + typedef typename C_S_Traits::size_type size_type; + + + Trivial_iterator() {} + Trivial_iterator(const I &i) : base_(i) {} + + // To allow conversion from iterator to const_iterator. + template + Trivial_iterator(const Trivial_iterator &t) + : base_(t.base()) {} + + reference operator*() const { return *base_; } + pointer operator->() const { return &*base_; } + + bool operator==(const Trivial_iterator &b) const { return base()==b.base(); } + bool operator!=(const Trivial_iterator &b) const { return base()!=b.base(); } + +private: + const Iterator & base() const { return base_; } + + Iterator base_; +}; + +#if defined(CGAL_CFG_NO_ITERATOR_TRAITS) && \ +!defined(CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT) +template < class I, class Ref, class Ptr, + class Val, class Dist, class Ctg > +#elif !defined __SUNPRO_CC +template < class I, + class Ref = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::reference, + class Ptr = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::pointer, + class Val = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::value_type, + class Dist = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::difference_type, + class Ctg = CGAL_TYPENAME_MSVC_NULL + std::iterator_traits::iterator_category> +#else +template < class I, + class Ref = typename CGALi::IT_rename::REF, + class Ptr = typename CGALi::IT_rename::PTR, + class Val = typename CGALi::IT_rename::VAL, + class Dist = typename CGALi::IT_rename::DIF, + class Ctg = typename CGALi::IT_rename::CAT > +#endif +class Comparable_iterator +{ +public: + typedef I Iterator; + typedef Comparable_iterator Self; + typedef Ctg iterator_category; + typedef Val value_type; + typedef Dist difference_type; +#ifdef CGAL_CFG_NO_ITERATOR_TRAITS + typedef Ref reference; + typedef Ptr pointer; +#else + typedef typename std::iterator_traits::reference reference; + typedef typename std::iterator_traits::pointer pointer; +#endif + // Special for circulators. + typedef I_Circulator_size_traits C_S_Traits; + typedef typename C_S_Traits::size_type size_type; + + + Comparable_iterator() {} + Comparable_iterator(const I &i) : base_(i) {} + + // To allow conversion from iterator to const_iterator. + template + Comparable_iterator(const Comparable_iterator &t) + : base_(t.base()) {} + + reference operator*() const { return *base_; } + pointer operator->() const { return &*base_; } + + bool operator==(const Comparable_iterator &b) const { return base()==b.base(); } + bool operator!=(const Comparable_iterator &b) const { return base()!=b.base(); } + + bool operator< (const Comparable_iterator &b) const { return base()< b.base(); } + bool operator> (const Comparable_iterator &b) const { return base()> b.base(); } + bool operator<=(const Comparable_iterator &b) const { return base()<=b.base(); } + bool operator>=(const Comparable_iterator &b) const { return base()>=b.base(); } + +private: + const Iterator & base() const { return base_; } + + Iterator base_; +}; + +#ifndef CGAL_NO_CONCEPT_CHECKING +# define CGAL_TRIVIAL_ITERATOR_CHECKER(X) CGAL::Trivial_iterator +# define CGAL_COMPARABLE_ITERATOR_CHECKER(X) CGAL::Comparable_iterator +#else +# define CGAL_TRIVIAL_ITERATOR_CHECKER(X) X +# define CGAL_COMPARABLE_ITERATOR_CHECKER(X) X +#endif + +CGAL_END_NAMESPACE + +#endif // CGAL_TRIVIAL_ITERATOR_H