Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71664 - in sandbox-branches/geometry/index_080_new: boost/geometry/extensions/index/rtree boost/geometry/extensions/index/rtree/visitors tests
From: adam.wulkiewicz_at_[hidden]
Date: 2011-05-02 08:14:45


Author: awulkiew
Date: 2011-05-02 08:14:44 EDT (Mon, 02 May 2011)
New Revision: 71664
URL: http://svn.boost.org/trac/boost/changeset/71664

Log:
searching time tests related code added
Text files modified:
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp | 3
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/rtree.hpp | 4
   sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp | 181 +++++++++++++++++++++++++--------------
   sandbox-branches/geometry/index_080_new/tests/additional_sizes_and_times.cpp | 20 ++-
   4 files changed, 133 insertions(+), 75 deletions(-)

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/node.hpp 2011-05-02 08:14:44 EDT (Mon, 02 May 2011)
@@ -1,8 +1,7 @@
 // Boost.Geometry (aka GGL, Generic Geometry Library)
 //
-// Boost.Index - R-tree details
+// Boost.Index - R-tree default nodes
 //
-// Copyright 2008 Federico J. Fernandez.
 // Copyright 2011 Adam Wulkiewicz.
 // Use, modification and distribution is subject to the Boost Software License,
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/rtree.hpp 2011-05-02 08:14:44 EDT (Mon, 02 May 2011)
@@ -72,7 +72,9 @@
     template <typename Geometry, typename OutIter>
     inline void find(Geometry const& geom, OutIter out_it) const
     {
- detail::rtree::visitors::find<value_type, translator_type, box_type, tag_type, Geometry, OutIter> find_v(m_translator, geom, out_it);
+ detail::rtree::visitors::find<value_type, translator_type, box_type, tag_type, Geometry, OutIter>
+ find_v(m_translator, geom, out_it);
+
         boost::apply_visitor(find_v, *m_root);
     }
 

Modified: sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp (original)
+++ sandbox-branches/geometry/index_080_new/boost/geometry/extensions/index/rtree/visitors/find.hpp 2011-05-02 08:14:44 EDT (Mon, 02 May 2011)
@@ -20,17 +20,88 @@
 
 namespace detail { namespace rtree { namespace visitors {
 
+//template <size_t N, typename T>
+//class array
+//{
+//public:
+// inline array()
+// : arr_elements(0)
+// {}
+//
+// inline void push(T const& v)
+// {
+// arr[arr_elements++] = v;
+// }
+//
+// inline T pop()
+// {
+// assert(0 < arr_elements);
+// return arr[--arr_elements];
+// }
+//
+// inline bool empty() const
+// {
+// return 0 == arr_elements;
+// }
+//
+// inline size_t size() const
+// {
+// return arr_elements;
+// }
+//
+//private:
+// boost::array<T, N> arr;
+// size_t arr_elements;
+//};
+//
+//template <typename Cont>
+//class dynamic
+//{
+//public:
+// typedef typename Cont::value_type value_type;
+//
+// inline void push(value_type const& v)
+// {
+// cont.push_back(v);
+// }
+//
+// inline value_type pop()
+// {
+// value_type v = cont.back();
+// cont.pop_back();
+// return v;
+// }
+//
+// inline bool empty() const
+// {
+// return cont.empty();
+// }
+//
+// inline size_t size() const
+// {
+// return cont.size();
+// }
+//
+// inline void clear()
+// {
+// cont.clear();
+// }
+//
+//private:
+// Cont cont;
+//};
+//
 //template <size_t N, typename Cont>
 //class array_semi_dynamic
 //{
 //public:
 // typedef typename Cont::value_type value_type;
 //
-// array_semi_dynamic()
+// inline array_semi_dynamic()
 // : arr_elements(0)
 // {}
 //
-// void push_back(value_type const& v)
+// inline void push(value_type const& v)
 // {
 // if ( arr_elements < N )
 // arr[arr_elements++] = v;
@@ -38,46 +109,27 @@
 // cont.push_back(v);
 // }
 //
-// void pop_back()
+// inline value_type pop()
 // {
 // if ( !cont.empty() )
-// cont.pop_back();
-// else
 // {
-// assert(0 < arr_elements);
-// --arr_elements;
-// }
-// }
-//
-// value_type & back()
-// {
-// if ( !cont.empty() )
-// return cont.back();
-// else
-// {
-// assert(0 < arr_elements);
-// return arr[arr_elements - 1];
+// value_type v = cont.back();
+// cont.pop_back();
+// return v;
 // }
-// }
-//
-// value_type const& back() const
-// {
-// if ( !cont.empty() )
-// return cont.back();
 // else
 // {
 // assert(0 < arr_elements);
-// return arr[arr_elements - 1];
+// return arr[--arr_elements];
 // }
 // }
 //
-// bool empty() const
+// inline bool empty() const
 // {
-// assert(cont.empty());
-// return 0 == arr_elements;
+// return cont.empty() && 0 == arr_elements;
 // }
 //
-// size_t size() const
+// inline size_t size() const
 // {
 // return arr_elements + cont.size();
 // }
@@ -103,42 +155,43 @@
 
     inline void operator()(internal_node const& n)
     {
- /*typedef typename internal_node::children_type children_type;
+ //typedef typename internal_node::children_type children_type;
 
- array_semi_dynamic<512, std::deque<node*> > nodes;
-
- for (typename children_type::const_iterator it = n.children.begin();
- it != n.children.end(); ++it)
- {
- if ( geometry::intersects(it->first, geom) )
- {
- nodes.push_back(it->second);
- }
- }
-
- while ( !nodes.empty() )
- {
- node *n = nodes.back();
- nodes.pop_back();
-
- if ( !boost::apply_visitor(visitors::is_leaf<Value, Box, Tag>(), *n) )
- {
- internal_node &in = boost::get<internal_node>(*n);
-
- for (typename children_type::const_iterator it = in.children.begin();
- it != in.children.end(); ++it)
- {
- if ( geometry::intersects(it->first, geom) )
- {
- nodes.push_back(it->second);
- }
- }
- }
- else
- {
- operator()(boost::get<leaf>(*n));
- }
- }*/
+ //array_semi_dynamic<1024, std::deque<node*> > nodes;
+ ////array<1024, node*> nodes;
+ ////dynamic< std::deque<node*> > nodes;
+ //
+ //for (typename children_type::const_iterator it = n.children.begin();
+ // it != n.children.end(); ++it)
+ //{
+ // if ( geometry::intersects(it->first, geom) )
+ // {
+ // nodes.push(it->second);
+ // }
+ //}
+
+ //while ( !nodes.empty() )
+ //{
+ // node *n = nodes.pop();
+
+ // if ( !boost::apply_visitor(visitors::is_leaf<Value, Box, Tag>(), *n) )
+ // {
+ // internal_node &in = boost::get<internal_node>(*n);
+
+ // for (typename children_type::const_iterator it = in.children.begin();
+ // it != in.children.end(); ++it)
+ // {
+ // if ( geometry::intersects(it->first, geom) )
+ // {
+ // nodes.push(it->second);
+ // }
+ // }
+ // }
+ // else
+ // {
+ // operator()(boost::get<leaf>(*n));
+ // }
+ //}
 
         typedef typename internal_node::children_type children_type;
 

Modified: sandbox-branches/geometry/index_080_new/tests/additional_sizes_and_times.cpp
==============================================================================
--- sandbox-branches/geometry/index_080_new/tests/additional_sizes_and_times.cpp (original)
+++ sandbox-branches/geometry/index_080_new/tests/additional_sizes_and_times.cpp 2011-05-02 08:14:44 EDT (Mon, 02 May 2011)
@@ -12,8 +12,12 @@
 {
     boost::timer tim;
 
- typedef boost::geometry::model::point<float, 2, boost::geometry::cs::cartesian> P;
- typedef boost::geometry::model::box<P> B;
+ namespace bg = boost::geometry;
+ namespace bgi = bg::index;
+
+ typedef bg::model::point<float, 2, bg::cs::cartesian> P;
+ typedef bg::model::box<P> B;
+ typedef bgi::rtree<std::pair<B, size_t>, bgi::default_parameter, bgi::linear_tag> RT;
 
     std::ifstream file_cfg("config.txt");
     size_t max_elems = 4;
@@ -41,7 +45,7 @@
     
     std::cout << "inserting time test...\n";
     tim.restart();
- boost::geometry::index::rtree< std::pair<B, size_t> > t(max_elems, min_elems);
+ RT t(max_elems, min_elems);
     for (size_t i = 0 ; i < values_count ; ++i )
     {
         float x = coords[i].first;
@@ -78,11 +82,11 @@
         std::cout << "saving...\n";
         std::ofstream file("save_new.txt", std::ofstream::trunc);
         file << std::fixed;
- boost::geometry::index::detail::rtree::visitors::save<
- boost::geometry::index::rtree< std::pair<B, size_t> >::value_type,
- boost::geometry::index::rtree< std::pair<B, size_t> >::translator_type,
- boost::geometry::index::rtree< std::pair<B, size_t> >::box_type,
- boost::geometry::index::rtree< std::pair<B, size_t> >::tag_type
+ bgi::detail::rtree::visitors::save<
+ RT::value_type,
+ RT::translator_type,
+ RT::box_type,
+ RT::tag_type
> saving_v(file, t.get_translator());
         t.apply_visitor(saving_v);
         std::cout << "saved...\n";


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