From 3f6f9dbb157eee69f60054827ceb1e9ab53665b9 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 10 Nov 1999 13:44:37 +0000 Subject: [PATCH] *** empty log message *** --- .../include/CGAL/N_step_adaptor_derived.h | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 Packages/STL_Extension/include/CGAL/N_step_adaptor_derived.h diff --git a/Packages/STL_Extension/include/CGAL/N_step_adaptor_derived.h b/Packages/STL_Extension/include/CGAL/N_step_adaptor_derived.h new file mode 100644 index 00000000000..3b930bfac11 --- /dev/null +++ b/Packages/STL_Extension/include/CGAL/N_step_adaptor_derived.h @@ -0,0 +1,150 @@ +// ============================================================================ +// +// Copyright (c) 1997, 1998, 1999 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 : $CGAL_Revision: $ +// release_date : $CGAL_Date: $ +// +// file : N_step_adaptor_derived.h +// chapter : $CGAL_Chapter: STL Extensions for CGAL $ +// package : $CGAL_Package: STL_Extension $ +// source : stl_extension.fw +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Michael Hoffmann +// Lutz Kettner +// +// coordinator : INRIA, Sophia Antipolis +// +// An iterator/circulator adaptor doing n-steps per increment. +// ============================================================================ + +#ifndef CGAL_N_STEP_ADAPTOR_DERIVED_H +#define CGAL_N_STEP_ADAPTOR_DERIVED_H 1 +#include + +CGAL_BEGIN_NAMESPACE + +template < class I, int N> +class N_step_adaptor_derived : public I { +public: + typedef I Iterator; + typedef I Circulator; + typedef N_step_adaptor_derived Self; + typedef typename I::iterator_category iterator_category; + typedef typename I::value_type value_type; + typedef typename I::difference_type difference_type; + typedef typename I::reference reference; + typedef typename I::pointer pointer; + // Special for circulators. + typedef I_Circulator_size_traits C_S_Traits; + typedef typename C_S_Traits::size_type size_type; + +// CREATION +// -------- + + N_step_adaptor_derived() {} + N_step_adaptor_derived( Iterator j) : I(j) {} + + template + N_step_adaptor_derived( const N_step_adaptor_derived& j) + : I( j.current_iterator()) {} + +// OPERATIONS Forward Category +// --------------------------- + + Circulator current_circulator() const { return *this;} + Iterator current_iterator() const { return *this;} + + Self& operator++() { + std::advance( (I&)*this, N); + return *this; + } + Self operator++(int) { + Self tmp = *this; + ++*this; + return tmp; + } + +// OPERATIONS Bidirectional Category +// --------------------------------- + + Self& operator--() { + std::advance( (I&)*this, -N); + return *this; + } + Self operator--(int) { + Self tmp = *this; + --*this; + return tmp; + } + +// OPERATIONS Random Access Category +// --------------------------------- + + Self min_circulator() const { return Self( I::min_circulator()); } + Self& operator+=( difference_type n) { + I::operator+=( difference_type(N * n)); + return *this; + } + Self operator+( difference_type n) const { + Self tmp = *this; + tmp += n; + return tmp; + } +#ifdef CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES + friend inline + Self + operator+( difference_type n, Self i) { + i = i + n; + return i; + } +#endif // CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES // + Self& operator-=( difference_type n) { + return operator+=( -n); + } + Self operator-( difference_type n) const { + Self tmp = *this; + return tmp += -n; + } + difference_type operator-( const Self& i) const { + return (I::operator-(i)) / N; + } + reference operator[]( difference_type n) const { + Self tmp = *this; + tmp += n; + return tmp.operator*(); + } +#ifdef CGAL_CFG_NO_ITERATOR_TRAITS +#ifndef CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT + friend inline iterator_category + iterator_category( const Self&) { return iterator_category(); } + friend inline value_type* + value_type( const Self&) { return (value_type*)(0); } + friend inline difference_type* + distance_type( const Self&) { return (difference_type*)(0); } + typedef _Circulator_traits C_Traits; + typedef typename C_Traits::category category; + friend inline category + query_circulator_or_iterator( const Self&) { return category(); } +#endif // CGAL_LIMITED_ITERATOR_TRAITS_SUPPORT +#endif // CGAL_CFG_NO_ITERATOR_TRAITS // +}; +#ifndef CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES +template < class I, int N> +inline +N_step_adaptor_derived +operator+( typename N_step_adaptor_derived::difference_type n, + N_step_adaptor_derived i) +{ return i += n; } +#endif // CGAL_CFG_NO_CONSTANTS_IN_FUNCTION_TEMPLATES // + +CGAL_END_NAMESPACE +#endif // CGAL_N_STEP_ADAPTOR_DERIVED_H // +// EOF //