diff --git a/STL_Extension/include/CGAL/Small_unordered_set.h b/STL_Extension/include/CGAL/Small_unordered_set.h index 7caf6e25a4b..b55d10c2ac6 100644 --- a/STL_Extension/include/CGAL/Small_unordered_set.h +++ b/STL_Extension/include/CGAL/Small_unordered_set.h @@ -12,6 +12,9 @@ #ifndef CGAL_SMALL_UNORDERED_SET_H #define CGAL_SMALL_UNORDERED_SET_H +#include +#include + namespace CGAL { diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2.h index 3ff1e9b078e..31c55ea277d 100644 --- a/Surface_sweep_2/include/CGAL/Surface_sweep_2.h +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2.h @@ -26,8 +26,7 @@ #include #include -#include -#include +#include #include namespace CGAL { @@ -102,7 +101,7 @@ public: typedef typename Base::Status_line_iterator Status_line_iterator; typedef std::vector Object_vector; - typedef random_access_input_iterator vector_inserter; + typedef Random_access_output_iterator vector_inserter; typedef typename Base::Subcurve_alloc Subcurve_alloc; protected: diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h deleted file mode 100644 index 6f6ce6dfd0a..00000000000 --- a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Curve_pair.h +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// Author(s) : Baruch Zukerman -// Ron Wein - -#ifndef CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H -#define CGAL_SURFACE_SWEEP_2_CURVE_PAIR_H - -#include - -#include - -/*! \file - * - * Definition of the Curve_pair class template and related functors. - */ - -namespace CGAL { -namespace Surface_sweep_2 { - -/*! \class - * - * A pair of subcurves. - */ -template -class Curve_pair { -public: - typedef Subcurve_ Subcurve; - -private: - // Data members: - std::pair m_pair; - -public: - /*! Construct default. */ - Curve_pair() {} - - /*! Construct from two subcurves. - */ - Curve_pair(Subcurve* sc1, Subcurve* sc2) - { m_pair = CGAL::make_sorted_pair(sc1, sc2); } - - /*! Obtain the first subcurve. */ - Subcurve* first() const { return m_pair.first; } - - /*! Obtain the second subcurve. */ - Subcurve* second() const { return m_pair.second; } - - std::pair pair() const - { - return m_pair; - } -}; - -/*! \struct - * Less functor for curve pairs. - */ -template -struct Less_curve_pair { - typedef Subcurve_ Subcurve; - typedef class Curve_pair Curve_pair; - - bool operator()(const Curve_pair& pair1, const Curve_pair& pair2) const - { - if (pair1.first() < pair2.first()) return true; - if (pair1.first() > pair2.first()) return false; - if (pair1.second() < pair2.second()) return true; - return false; - } -}; - -template -std::size_t hash_value(const Curve_pair& cp) -{ - return boost::hash >()(cp.pair()); -} - -/*! \struct - * Equaility functor for curve pairs. - */ -template -struct Equal_curve_pair { - typedef Subcurve_ Subcurve; - typedef class Curve_pair Curve_pair; - - bool operator()(const Curve_pair& pair1, const Curve_pair& pair2) const - { - return ((pair1.first() == pair2.first()) && - (pair1.second() == pair2.second())); - } -}; - -/*! \class - * A random-access iterator that can automatically resize its container. - */ -template -class random_access_input_iterator { -public: - typedef Container_ Container; - typedef typename Container::value_type value_type; - typedef random_access_input_iterator Self; - -private: - // Data members: - Container* m_container; // The container. - unsigned int m_index; // The current index. - -public: - random_access_input_iterator() {} - - random_access_input_iterator(Container& _container, unsigned int _index = 0) : - m_container(&_container), - m_index(_index) - {} - - value_type& operator*() - { - if(m_index >= m_container->capacity()) { - m_container->reserve(2 * m_index + 1); - m_container->resize(m_index+1); - } - else if(m_index >= m_container->size()) - m_container->resize(m_index+1); - return (*m_container)[m_index]; - } - - Self& operator++() - { - ++m_index; - return (*this); - } - - Self operator++ (int) - { - Self temp = *this; - ++m_index; - return (temp); - } - - Self& operator--() - { - --m_index; - return (*this); - } - - Self operator--(int) - { - Self temp = *this; - --m_index; - return (temp); - } - - bool operator==(const Self& other) - { - CGAL_precondition(m_container == other.m_container); - return (m_index == other.m_index); - } - - bool operator!=(const Self& other) - { - CGAL_precondition(m_container == other.m_container); - return !(*this == other); - } - - unsigned int operator-(const Self& other) - { - CGAL_precondition(m_container == other.m_container); - return (m_index - other.m_index); - } -}; - -} // namespace Surface_sweep_2 -} // namespace CGAL - -#endif diff --git a/Surface_sweep_2/include/CGAL/Surface_sweep_2/Random_access_output_iterator.h b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Random_access_output_iterator.h new file mode 100644 index 00000000000..457f2064e03 --- /dev/null +++ b/Surface_sweep_2/include/CGAL/Surface_sweep_2/Random_access_output_iterator.h @@ -0,0 +1,105 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Baruch Zukerman +// Ron Wein + +#ifndef CGAL_SURFACE_SWEEP_2_RANDOM_ACCESS_OUTPUT_ITERATOR_H +#define CGAL_SURFACE_SWEEP_2_RANDOM_ACCESS_OUTPUT_ITERATOR_H + +#include + +#include + +namespace CGAL { +namespace Surface_sweep_2 { + +/*! \class + * A random-access iterator that can automatically resize its container. + */ +template +class Random_access_output_iterator { +public: + typedef Container_ Container; + typedef typename Container::value_type value_type; + typedef Random_access_output_iterator Self; + +private: + // Data members: + Container* m_container; // The container. + unsigned int m_index; // The current index. + +public: + Random_access_output_iterator() {} + + Random_access_output_iterator(Container& _container, unsigned int _index = 0) : + m_container(&_container), + m_index(_index) + {} + + value_type& operator*() + { + if(m_index >= m_container->capacity()) { + m_container->reserve(2 * m_index + 1); + m_container->resize(m_index+1); + } + else if(m_index >= m_container->size()) + m_container->resize(m_index+1); + return (*m_container)[m_index]; + } + + Self& operator++() + { + ++m_index; + return (*this); + } + + Self operator++ (int) + { + Self temp = *this; + ++m_index; + return (temp); + } + + Self& operator--() + { + --m_index; + return (*this); + } + + Self operator--(int) + { + Self temp = *this; + --m_index; + return (temp); + } + + bool operator==(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return (m_index == other.m_index); + } + + bool operator!=(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return !(*this == other); + } + + unsigned int operator-(const Self& other) + { + CGAL_precondition(m_container == other.m_container); + return (m_index - other.m_index); + } +}; + +} // namespace Surface_sweep_2 +} // namespace CGAL + +#endif