|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81436 - in sandbox-branches/geometry/index_dev/boost/geometry/extensions/index: . adaptors filters rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2012-11-20 08:45:49
Author: awulkiew
Date: 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
New Revision: 81436
URL: http://svn.boost.org/trac/boost/changeset/81436
Log:
Safety issue fixed in pushable_array.
Filenames related to filters(old name) changed to adaptors.
Added:
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/nearest_query.hpp (contents, props changed)
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/spatial_query.hpp (contents, props changed)
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/adaptors.hpp (contents, props changed)
Removed:
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/filters/
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/filters.hpp
Text files modified:
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/pushable_array.hpp | 3 ++-
sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
Added: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/nearest_query.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/nearest_query.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
@@ -0,0 +1,101 @@
+// Boost.Geometry Index
+//
+// Nearest neighbour query range adaptor
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ADAPTORS_NEAREST_QUERY_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ADAPTORS_NEAREST_QUERY_HPP
+
+namespace boost { namespace geometry { namespace index {
+
+namespace adaptors {
+
+template <typename Index>
+class nearest_query_range
+{
+ BOOST_MPL_ASSERT_MSG(
+ (false),
+ NOT_IMPLEMENTED_FOR_THIS_INDEX,
+ (nearest_query_range));
+
+ typedef int* iterator;
+ typedef const int* const_iterator;
+
+ template <typename DistancesPredicates, typename Predicates>
+ inline nearest_query_range(
+ Index const&,
+ DistancesPredicates const&,
+ size_t,
+ Predicates const&
+ )
+ {}
+
+ inline iterator begin() { return 0; }
+ inline iterator end() { return 0; }
+ inline const_iterator begin() const { return 0; }
+ inline const_iterator end() const { return 0; }
+};
+
+namespace detail {
+
+// TODO: awulkiew - consider removing references from predicates
+
+template<typename DistancesPredicates, typename Predicates>
+struct nearest_query
+{
+ inline nearest_query(
+ DistancesPredicates const& dpred,
+ size_t k,
+ Predicates const& pred
+ )
+ : distances_predicates(dpred)
+ , count(k)
+ , predicates(pred)
+ {}
+
+ DistancesPredicates const& distances_predicates;
+ size_t count;
+ Predicates const& predicates;
+};
+
+} // namespace detail
+
+template <typename DistancesPredicates, typename Predicates>
+detail::nearest_query<DistancesPredicates, Predicates>
+nearest_queried(
+ DistancesPredicates const& dpred,
+ size_t k,
+ Predicates const& pred)
+{
+ return detail::nearest_query<DistancesPredicates, Predicates>(dpred, k, pred);
+}
+
+template <typename DistancesPredicates>
+detail::nearest_query<DistancesPredicates, index::detail::empty>
+nearest_queried(
+ DistancesPredicates const& dpred,
+ size_t k)
+{
+ return detail::nearest_query<DistancesPredicates, index::detail::empty>(dpred, k, index::detail::empty());
+}
+
+} // namespace adaptors
+
+template<typename Index, typename DistancesPredicates, typename Predicates>
+index::adaptors::nearest_query_range<Index>
+operator|(
+ Index const& si,
+ index::adaptors::detail::nearest_query<DistancesPredicates, Predicates> const& f)
+{
+ return index::adaptors::nearest_query_range<Index>(
+ si, f.distances_predicates, f.count, f.predicates);
+}
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ADAPTORS_NEAREST_QUERY_HPP
Added: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/spatial_query.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/adaptors/spatial_query.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
@@ -0,0 +1,77 @@
+// Boost.Geometry Index
+//
+// Spatial query range adaptor
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ADAPTORS_SPATIAL_QUERY_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ADAPTORS_SPATIAL_QUERY_HPP
+
+namespace boost { namespace geometry { namespace index {
+
+namespace adaptors {
+
+template <typename Index>
+class spatial_query_range
+{
+ BOOST_MPL_ASSERT_MSG(
+ (false),
+ NOT_IMPLEMENTED_FOR_THIS_INDEX,
+ (spatial_query_range));
+
+ typedef int* iterator;
+ typedef const int* const_iterator;
+
+ template <typename Predicates>
+ inline spatial_query_range(
+ Index const&,
+ Predicates const&)
+ {}
+
+ inline iterator begin() { return 0; }
+ inline iterator end() { return 0; }
+ inline const_iterator begin() const { return 0; }
+ inline const_iterator end() const { return 0; }
+};
+
+namespace detail {
+
+// TODO: awulkiew - consider removing reference from predicates
+
+template<typename Predicates>
+struct spatial_query
+{
+ inline explicit spatial_query(Predicates const& pred)
+ : predicates(pred)
+ {}
+
+ Predicates const& predicates;
+};
+
+} // namespace detail
+
+template <typename Predicates>
+detail::spatial_query<Predicates>
+spatial_queried(Predicates const& pred)
+{
+ return detail::spatial_query<Predicates>(pred);
+}
+
+} // namespace adaptors
+
+template<typename Index, typename Predicates>
+index::adaptors::spatial_query_range<Index>
+operator|(
+ Index const& si,
+ index::adaptors::detail::spatial_query<Predicates> const& f)
+{
+ return index::adaptors::spatial_query_range<Index>(si, f.predicates);
+}
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ADAPTORS_SPATIAL_QUERY_HPP
Modified: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/pushable_array.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/pushable_array.hpp (original)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/pushable_array.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
@@ -151,7 +151,8 @@
inline void push_back(Element const& v)
{
BOOST_GEOMETRY_INDEX_ASSERT(m_size < Capacity, "can't further increase the size of the container");
- m_array[m_size++] = v;
+ m_array[m_size] = v;
+ ++m_size;
}
inline void pop_back()
Added: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/adaptors.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/adaptors.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
@@ -0,0 +1,85 @@
+// Boost.Geometry Index
+//
+// R-tree queries range adaptors
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_RTREE_ADAPTORS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_ADAPTORS_HPP
+
+#include <deque>
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/extensions/index/adaptors/spatial_query.hpp>
+#include <boost/geometry/extensions/index/adaptors/nearest_query.hpp>
+
+namespace boost { namespace geometry { namespace index {
+
+template <typename Value, typename Options, typename Translator, typename Allocator>
+class rtree;
+
+namespace adaptors {
+
+template <typename Value, typename Options, typename Translator, typename Allocator>
+class spatial_query_range< index::rtree<Value, Options, Translator, Allocator> >
+{
+public:
+ typedef std::vector<Value> result_type;
+ typedef typename result_type::iterator iterator;
+ typedef typename result_type::const_iterator const_iterator;
+
+ template <typename Predicates>
+ inline spatial_query_range(
+ index::rtree<Value, Options, Translator, Allocator> const& rtree,
+ Predicates const& pred
+ )
+ {
+ rtree.spatial_query(pred, std::back_inserter(m_result));
+ }
+
+ inline iterator begin() { return m_result.begin(); }
+ inline iterator end() { return m_result.end(); }
+ inline const_iterator begin() const { return m_result.begin(); }
+ inline const_iterator end() const { return m_result.end(); }
+
+private:
+ result_type m_result;
+};
+
+template <typename Value, typename Options, typename Translator, typename Allocator>
+class nearest_query_range< index::rtree<Value, Options, Translator, Allocator> >
+{
+public:
+ typedef std::vector<Value> result_type;
+ typedef typename result_type::iterator iterator;
+ typedef typename result_type::const_iterator const_iterator;
+
+ template <typename DistancesPredicates, typename Predicates>
+ inline nearest_query_range(
+ index::rtree<Value, Options, Translator, Allocator> const& rtree,
+ DistancesPredicates const& dpred,
+ size_t k,
+ Predicates const& pred
+ )
+ {
+ rtree.nearest_query(dpred, k, pred, std::back_inserter(m_result));
+ }
+
+ inline iterator begin() { return m_result.begin(); }
+ inline iterator end() { return m_result.end(); }
+ inline const_iterator begin() const { return m_result.begin(); }
+ inline const_iterator end() const { return m_result.end(); }
+
+private:
+ result_type m_result;
+};
+
+} // namespace adaptors
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_ADAPTORS_HPP
Deleted: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/filters.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/filters.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
+++ (empty file)
@@ -1,85 +0,0 @@
-// Boost.Geometry Index
-//
-// R-tree queries filters implementation
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_RTREE_FILTERS_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_FILTERS_HPP
-
-#include <deque>
-#include <boost/static_assert.hpp>
-
-#include <boost/geometry/extensions/index/filters/query_filter.hpp>
-#include <boost/geometry/extensions/index/filters/nearest_filter.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-template <typename Value, typename Options, typename Translator, typename Allocator>
-class rtree;
-
-namespace adaptors {
-
-template <typename Value, typename Options, typename Translator, typename Allocator>
-class spatial_query_range< index::rtree<Value, Options, Translator, Allocator> >
-{
-public:
- typedef std::vector<Value> result_type;
- typedef typename result_type::iterator iterator;
- typedef typename result_type::const_iterator const_iterator;
-
- template <typename Predicates>
- inline spatial_query_range(
- index::rtree<Value, Options, Translator, Allocator> const& rtree,
- Predicates const& pred
- )
- {
- rtree.spatial_query(pred, std::back_inserter(m_result));
- }
-
- inline iterator begin() { return m_result.begin(); }
- inline iterator end() { return m_result.end(); }
- inline const_iterator begin() const { return m_result.begin(); }
- inline const_iterator end() const { return m_result.end(); }
-
-private:
- result_type m_result;
-};
-
-template <typename Value, typename Options, typename Translator, typename Allocator>
-class nearest_query_range< index::rtree<Value, Options, Translator, Allocator> >
-{
-public:
- typedef std::vector<Value> result_type;
- typedef typename result_type::iterator iterator;
- typedef typename result_type::const_iterator const_iterator;
-
- template <typename DistancesPredicates, typename Predicates>
- inline nearest_query_range(
- index::rtree<Value, Options, Translator, Allocator> const& rtree,
- DistancesPredicates const& dpred,
- size_t k,
- Predicates const& pred
- )
- {
- rtree.nearest_query(dpred, k, pred, std::back_inserter(m_result));
- }
-
- inline iterator begin() { return m_result.begin(); }
- inline iterator end() { return m_result.end(); }
- inline const_iterator begin() const { return m_result.begin(); }
- inline const_iterator end() const { return m_result.end(); }
-
-private:
- result_type m_result;
-};
-
-} // namespace adaptors
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_FILTERS_HPP
Modified: sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index_dev/boost/geometry/extensions/index/rtree/rtree.hpp 2012-11-20 08:45:48 EST (Tue, 20 Nov 2012)
@@ -26,7 +26,7 @@
#include <boost/geometry/extensions/index/rtree/options.hpp>
#include <boost/geometry/extensions/index/predicates.hpp>
-#include <boost/geometry/extensions/index/rtree/filters.hpp>
+#include <boost/geometry/extensions/index/rtree/adaptors.hpp>
#include <boost/geometry/extensions/index/rtree/node/node.hpp>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk