mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 05:24:02 +00:00
geometry.index: added stl container-like typedefs in rtree (reference, pointer, etc.), added type-erased iterator - currently may be enabled by define.
[SVN r84071]
This commit is contained in:
parent
7c43145cf8
commit
72e5b48bba
@ -164,9 +164,20 @@ class allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>
|
|||||||
typename leaf<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
|
typename leaf<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_d_mem_dynamic_tag>, node_d_mem_dynamic_tag>::type
|
||||||
>::other
|
>::other
|
||||||
{
|
{
|
||||||
|
typedef typename Allocator::template rebind<
|
||||||
|
Value
|
||||||
|
>::other value_allocator_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef typename Allocator::size_type size_type;
|
|
||||||
|
typedef Value value_type;
|
||||||
|
typedef typename value_allocator_type::reference reference;
|
||||||
|
typedef typename value_allocator_type::const_reference const_reference;
|
||||||
|
typedef typename value_allocator_type::size_type size_type;
|
||||||
|
typedef typename value_allocator_type::difference_type difference_type;
|
||||||
|
typedef typename value_allocator_type::pointer pointer;
|
||||||
|
typedef typename value_allocator_type::const_pointer const_pointer;
|
||||||
|
|
||||||
typedef typename Allocator::template rebind<
|
typedef typename Allocator::template rebind<
|
||||||
typename node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
|
typename node<Value, Parameters, Box, allocators, node_d_mem_dynamic_tag>::type
|
||||||
|
@ -113,9 +113,20 @@ class allocators<Allocator, Value, Parameters, Box, node_d_mem_static_tag>
|
|||||||
>::type
|
>::type
|
||||||
>::other
|
>::other
|
||||||
{
|
{
|
||||||
|
typedef typename Allocator::template rebind<
|
||||||
|
Value
|
||||||
|
>::other value_allocator_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef typename Allocator::size_type size_type;
|
|
||||||
|
typedef Value value_type;
|
||||||
|
typedef value_type & reference;
|
||||||
|
typedef const value_type & const_reference;
|
||||||
|
typedef typename value_allocator_type::size_type size_type;
|
||||||
|
typedef typename value_allocator_type::difference_type difference_type;
|
||||||
|
typedef typename value_allocator_type::pointer pointer;
|
||||||
|
typedef typename value_allocator_type::const_pointer const_pointer;
|
||||||
|
|
||||||
typedef typename Allocator::template rebind<
|
typedef typename Allocator::template rebind<
|
||||||
typename node<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
|
typename node<Value, Parameters, Box, allocators, node_d_mem_static_tag>::type
|
||||||
|
@ -96,9 +96,20 @@ class allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>
|
|||||||
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>, node_s_mem_dynamic_tag>::type
|
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_dynamic_tag>, node_s_mem_dynamic_tag>::type
|
||||||
>::other
|
>::other
|
||||||
{
|
{
|
||||||
|
typedef typename Allocator::template rebind<
|
||||||
|
Value
|
||||||
|
>::other value_allocator_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef typename Allocator::size_type size_type;
|
|
||||||
|
typedef Value value_type;
|
||||||
|
typedef typename value_allocator_type::reference reference;
|
||||||
|
typedef typename value_allocator_type::const_reference const_reference;
|
||||||
|
typedef typename value_allocator_type::size_type size_type;
|
||||||
|
typedef typename value_allocator_type::difference_type difference_type;
|
||||||
|
typedef typename value_allocator_type::pointer pointer;
|
||||||
|
typedef typename value_allocator_type::const_pointer const_pointer;
|
||||||
|
|
||||||
typedef typename Allocator::template rebind<
|
typedef typename Allocator::template rebind<
|
||||||
typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
|
typename node<Value, Parameters, Box, allocators, node_s_mem_dynamic_tag>::type
|
||||||
|
@ -94,9 +94,20 @@ struct allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>
|
|||||||
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>, node_s_mem_static_tag>::type
|
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_s_mem_static_tag>, node_s_mem_static_tag>::type
|
||||||
>::other
|
>::other
|
||||||
{
|
{
|
||||||
|
typedef typename Allocator::template rebind<
|
||||||
|
Value
|
||||||
|
>::other value_allocator_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef typename Allocator::size_type size_type;
|
|
||||||
|
typedef Value value_type;
|
||||||
|
typedef value_type & reference;
|
||||||
|
typedef const value_type & const_reference;
|
||||||
|
typedef typename value_allocator_type::size_type size_type;
|
||||||
|
typedef typename value_allocator_type::difference_type difference_type;
|
||||||
|
typedef typename value_allocator_type::pointer pointer;
|
||||||
|
typedef typename value_allocator_type::const_pointer const_pointer;
|
||||||
|
|
||||||
typedef typename Allocator::template rebind<
|
typedef typename Allocator::template rebind<
|
||||||
typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
|
typename node<Value, Parameters, Box, allocators, node_s_mem_static_tag>::type
|
||||||
|
@ -364,6 +364,7 @@ public:
|
|||||||
> value_distances_predicates_check;
|
> value_distances_predicates_check;
|
||||||
|
|
||||||
typedef typename Allocators::size_type size_type;
|
typedef typename Allocators::size_type size_type;
|
||||||
|
typedef typename Allocators::const_reference const_reference;
|
||||||
typedef typename Allocators::node_pointer node_pointer;
|
typedef typename Allocators::node_pointer node_pointer;
|
||||||
|
|
||||||
static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
|
static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
|
||||||
@ -390,7 +391,7 @@ public:
|
|||||||
BOOST_ASSERT_MSG(0 < max_count(), "k must be greather than 0");
|
BOOST_ASSERT_MSG(0 < max_count(), "k must be greather than 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
Value const& dereference() const
|
const_reference dereference() const
|
||||||
{
|
{
|
||||||
return *(neighbors[current_neighbor].second);
|
return *(neighbors[current_neighbor].second);
|
||||||
}
|
}
|
||||||
@ -622,14 +623,12 @@ class nearest_query_iterator
|
|||||||
typedef visitors::nearest_query_incremental<Value, Options, Translator, Box, Allocators, Predicates, NearestPredicateIndex> visitor_type;
|
typedef visitors::nearest_query_incremental<Value, Options, Translator, Box, Allocators, Predicates, NearestPredicateIndex> visitor_type;
|
||||||
typedef typename visitor_type::node_pointer node_pointer;
|
typedef typename visitor_type::node_pointer node_pointer;
|
||||||
|
|
||||||
typedef typename Allocators::allocator_type::template rebind<Value>::other allocator_type;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::input_iterator_tag iterator_category;
|
typedef std::input_iterator_tag iterator_category;
|
||||||
typedef const Value value_type;
|
typedef Value value_type;
|
||||||
typedef Value const& reference;
|
typedef typename Allocators::const_reference reference;
|
||||||
typedef typename allocator_type::difference_type difference_type;
|
typedef typename Allocators::difference_type difference_type;
|
||||||
typedef typename allocator_type::const_pointer pointer;
|
typedef typename Allocators::const_pointer pointer;
|
||||||
|
|
||||||
inline nearest_query_iterator(Translator const& t, Predicates const& p)
|
inline nearest_query_iterator(Translator const& t, Predicates const& p)
|
||||||
: m_visitor(t, p)
|
: m_visitor(t, p)
|
||||||
|
@ -85,6 +85,7 @@ public:
|
|||||||
typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
|
typedef typename rtree::leaf<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
|
||||||
|
|
||||||
typedef typename Allocators::size_type size_type;
|
typedef typename Allocators::size_type size_type;
|
||||||
|
typedef typename Allocators::const_reference const_reference;
|
||||||
typedef typename Allocators::node_pointer node_pointer;
|
typedef typename Allocators::node_pointer node_pointer;
|
||||||
|
|
||||||
typedef typename rtree::elements_type<internal_node>::type::const_iterator internal_iterator;
|
typedef typename rtree::elements_type<internal_node>::type::const_iterator internal_iterator;
|
||||||
@ -112,7 +113,7 @@ public:
|
|||||||
m_value_index = 0;
|
m_value_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value const& dereference() const
|
const_reference dereference() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT_MSG(m_values, "not dereferencable");
|
BOOST_ASSERT_MSG(m_values, "not dereferencable");
|
||||||
return (*m_values)[m_value_index];
|
return (*m_values)[m_value_index];
|
||||||
@ -192,14 +193,12 @@ class spatial_query_iterator
|
|||||||
typedef visitors::spatial_query_incremental<Value, Options, Translator, Box, Allocators, Predicates> visitor_type;
|
typedef visitors::spatial_query_incremental<Value, Options, Translator, Box, Allocators, Predicates> visitor_type;
|
||||||
typedef typename visitor_type::node_pointer node_pointer;
|
typedef typename visitor_type::node_pointer node_pointer;
|
||||||
|
|
||||||
typedef typename Allocators::allocator_type::template rebind<Value>::other allocator_type;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::input_iterator_tag iterator_category;
|
typedef std::input_iterator_tag iterator_category;
|
||||||
typedef const Value value_type;
|
typedef Value value_type;
|
||||||
typedef Value const& reference;
|
typedef typename Allocators::const_reference reference;
|
||||||
typedef typename allocator_type::difference_type difference_type;
|
typedef typename Allocators::difference_type difference_type;
|
||||||
typedef typename allocator_type::const_pointer pointer;
|
typedef typename Allocators::const_pointer pointer;
|
||||||
|
|
||||||
inline spatial_query_iterator(Translator const& t, Predicates const& p)
|
inline spatial_query_iterator(Translator const& t, Predicates const& p)
|
||||||
: m_visitor(t, p)
|
: m_visitor(t, p)
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
// Boost.Geometry Index
|
||||||
|
//
|
||||||
|
// Type-erased iterators
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||||
|
//
|
||||||
|
// Use, modification and distribution is subject to the Boost Software License,
|
||||||
|
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
|
||||||
|
#define BOOST_GEOMETRY_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
|
||||||
|
|
||||||
|
#include <boost/type_erasure/any.hpp>
|
||||||
|
#include <boost/type_erasure/operators.hpp>
|
||||||
|
|
||||||
|
namespace boost { namespace geometry { namespace index { namespace detail {
|
||||||
|
|
||||||
|
template<typename T, typename ValueType, typename Reference, typename Pointer, typename DifferenceType>
|
||||||
|
struct single_pass_iterator_concept :
|
||||||
|
::boost::mpl::vector<
|
||||||
|
::boost::type_erasure::copy_constructible<T>,
|
||||||
|
::boost::type_erasure::equality_comparable<T>,
|
||||||
|
::boost::type_erasure::dereferenceable<Reference, T>,
|
||||||
|
::boost::type_erasure::assignable<T>,
|
||||||
|
::boost::type_erasure::incrementable<T>
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <typename ValueType, typename Reference, typename Pointer, typename DifferenceType>
|
||||||
|
struct single_pass_iterator_type
|
||||||
|
{
|
||||||
|
typedef ::boost::type_erasure::any<
|
||||||
|
single_pass_iterator_concept<
|
||||||
|
::boost::type_erasure::_self, ValueType, Reference, Pointer, DifferenceType
|
||||||
|
>
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
}}}} // namespace boost::geometry::index::detail
|
||||||
|
|
||||||
|
namespace boost { namespace type_erasure {
|
||||||
|
|
||||||
|
template<typename T, typename ValueType, typename Reference, typename Pointer, typename DifferenceType, typename Base>
|
||||||
|
struct concept_interface<
|
||||||
|
::boost::geometry::index::detail::single_pass_iterator_concept<
|
||||||
|
T, ValueType, Reference, Pointer, DifferenceType
|
||||||
|
>, Base, T>
|
||||||
|
: Base
|
||||||
|
{
|
||||||
|
typedef ValueType value_type;
|
||||||
|
typedef Reference reference;
|
||||||
|
typedef Pointer pointer;
|
||||||
|
typedef DifferenceType difference_type;
|
||||||
|
typedef ::std::input_iterator_tag iterator_category;
|
||||||
|
};
|
||||||
|
|
||||||
|
}} // namespace boost::type_erasure
|
||||||
|
|
||||||
|
#endif // BOOST_GEOMETRY_INDEX_DETAIL_TYPE_ERASED_ITERATORS_HPP
|
@ -57,6 +57,10 @@
|
|||||||
|
|
||||||
#include <boost/geometry/index/inserter.hpp>
|
#include <boost/geometry/index/inserter.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
|
||||||
|
#include <boost/geometry/index/detail/type_erased_iterators.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
// TODO change the name to bounding_tree
|
// TODO change the name to bounding_tree
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -117,14 +121,12 @@ public:
|
|||||||
typedef Value value_type;
|
typedef Value value_type;
|
||||||
/*! \brief R-tree parameters type. */
|
/*! \brief R-tree parameters type. */
|
||||||
typedef Parameters parameters_type;
|
typedef Parameters parameters_type;
|
||||||
/*! \brief The type of allocator used by the container. */
|
|
||||||
typedef Allocator allocator_type;
|
|
||||||
/*! \brief Unsigned integral type used by the container. */
|
|
||||||
typedef typename allocator_type::size_type size_type;
|
|
||||||
/*! \brief The function object extracting Indexable from Value. */
|
/*! \brief The function object extracting Indexable from Value. */
|
||||||
typedef IndexableGetter indexable_getter;
|
typedef IndexableGetter indexable_getter;
|
||||||
/*! \brief The function object comparing objects of type Value. */
|
/*! \brief The function object comparing objects of type Value. */
|
||||||
typedef EqualTo value_equal;
|
typedef EqualTo value_equal;
|
||||||
|
/*! \brief The type of allocator used by the container. */
|
||||||
|
typedef Allocator allocator_type;
|
||||||
|
|
||||||
// TODO: SHOULD THIS TYPE BE REMOVED?
|
// TODO: SHOULD THIS TYPE BE REMOVED?
|
||||||
/*! \brief The Indexable type to which Value is translated. */
|
/*! \brief The Indexable type to which Value is translated. */
|
||||||
@ -152,6 +154,21 @@ private:
|
|||||||
typedef typename allocators_type::node_pointer node_pointer;
|
typedef typename allocators_type::node_pointer node_pointer;
|
||||||
typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
|
typedef ::boost::container::allocator_traits<Allocator> allocator_traits_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*! \brief Type of reference to Value. */
|
||||||
|
typedef typename allocators_type::reference reference;
|
||||||
|
/*! \brief Type of reference to const Value. */
|
||||||
|
typedef typename allocators_type::const_reference const_reference;
|
||||||
|
/*! \brief Type of pointer to Value. */
|
||||||
|
typedef typename allocators_type::pointer pointer;
|
||||||
|
/*! \brief Type of pointer to const Value. */
|
||||||
|
typedef typename allocators_type::const_pointer const_pointer;
|
||||||
|
/*! \brief Type of difference type. */
|
||||||
|
typedef typename allocators_type::difference_type difference_type;
|
||||||
|
/*! \brief Unsigned integral type used by the container. */
|
||||||
|
typedef typename allocators_type::size_type size_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -724,6 +741,14 @@ public:
|
|||||||
|
|
||||||
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
||||||
|
|
||||||
|
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
|
||||||
|
|
||||||
|
typedef typename index::detail::single_pass_iterator_type<
|
||||||
|
value_type, const_reference, const_pointer, difference_type
|
||||||
|
>::type const_query_iterator;
|
||||||
|
|
||||||
|
#endif // BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
|
||||||
|
|
||||||
template <typename Predicates>
|
template <typename Predicates>
|
||||||
typename boost::mpl::if_c<
|
typename boost::mpl::if_c<
|
||||||
detail::predicates_count_nearest<Predicates>::value == 0,
|
detail::predicates_count_nearest<Predicates>::value == 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user