Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:31

0001 // Boost.Geometry Index
0002 //
0003 // R-tree iterators
0004 //
0005 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2021.
0008 // Modifications copyright (c) 2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 //
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
0014 
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP
0017 
0018 #include <iterator>
0019 
0020 #include <boost/geometry/index/detail/rtree/visitors/iterator.hpp>
0021 
0022 namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators {
0023 
0024 template <typename Value, typename Allocators>
0025 struct end_iterator
0026 {
0027     typedef std::forward_iterator_tag iterator_category;
0028     typedef Value value_type;
0029     typedef typename Allocators::const_reference reference;
0030     typedef typename Allocators::difference_type difference_type;
0031     typedef typename Allocators::const_pointer pointer;
0032 
0033     reference operator*() const
0034     {
0035         BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable");
0036         pointer p(0);
0037         return *p;
0038     }
0039 
0040     const value_type * operator->() const
0041     {
0042         BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable");
0043         const value_type * p = 0;
0044         return p;
0045     }
0046 
0047     end_iterator & operator++()
0048     {
0049         BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable");
0050         return *this;
0051     }
0052 
0053     end_iterator operator++(int)
0054     {
0055         BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable");
0056         return *this;
0057     }
0058 
0059     friend bool operator==(end_iterator const& /*l*/, end_iterator const& /*r*/)
0060     {
0061         return true;
0062     }
0063 };
0064 
0065 template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
0066 class iterator
0067 {
0068     typedef visitors::iterator<Value, Options, Translator, Box, Allocators> visitor_type;
0069     typedef typename visitor_type::node_pointer node_pointer;
0070 
0071 public:
0072     typedef std::forward_iterator_tag iterator_category;
0073     typedef Value value_type;
0074     typedef typename Allocators::const_reference reference;
0075     typedef typename Allocators::difference_type difference_type;
0076     typedef typename Allocators::const_pointer pointer;
0077 
0078     inline iterator()
0079     {}
0080 
0081     inline iterator(node_pointer root)
0082     {
0083         m_visitor.initialize(root);
0084     }
0085 
0086     reference operator*() const
0087     {
0088         return m_visitor.dereference();
0089     }
0090 
0091     const value_type * operator->() const
0092     {
0093         return boost::addressof(m_visitor.dereference());
0094     }
0095 
0096     iterator & operator++()
0097     {
0098         m_visitor.increment();
0099         return *this;
0100     }
0101 
0102     iterator operator++(int)
0103     {
0104         iterator temp = *this;
0105         this->operator++();
0106         return temp;
0107     }
0108 
0109     friend bool operator==(iterator const& l, iterator const& r)
0110     {
0111         return l.m_visitor == r.m_visitor;
0112     }
0113 
0114     friend bool operator==(iterator const& l, end_iterator<Value, Allocators> const& /*r*/)
0115     {
0116         return l.m_visitor.is_end();
0117     }
0118 
0119     friend bool operator==(end_iterator<Value, Allocators> const& /*l*/, iterator const& r)
0120     {
0121         return r.m_visitor.is_end();
0122     }
0123 
0124 private:
0125     visitor_type m_visitor;
0126 };
0127 
0128 }}}}}} // namespace boost::geometry::index::detail::rtree::iterators
0129 
0130 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP