rtree query and std::back_inserter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rtree query and std::back_inserter

Hussein Almashouq
Hi to all I'm using the rtree*  to load  1M > data points . Then  I use the rtree query to different intersection query  like 

found +=rtree.query(bgi::intersects(qbox), std::back_inserter(result));

currently I'm interested in getting the count of results rather than inserting into the result vector 

I have to two question 

1. is possible to skip std::back_inserter step and do a query that finds the count only.
2. How can improve the performance of the  std::back_inserter methods as my results are N^2 where N > 1M usually . ( check this post https://pkisensee.wordpress.com/2011/06/02/efficient-stl-insertion-tip-of-the-month/)


Best Regards 

Hussein


This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.
_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: rtree query and std::back_inserter

Adam Wulkiewicz
Hi Hussein,

Hussein Almashouq wrote:
Hi to all I'm using the rtree*  to load  1M > data points . Then  I use the rtree query to different intersection query  like 

found +=rtree.query(bgi::intersects(qbox), std::back_inserter(result));

currently I'm interested in getting the count of results rather than inserting into the result vector 

I have to two question 

1. is possible to skip std::back_inserter step and do a query that finds the count only.
2. How can improve the performance of the  std::back_inserter methods as my results are N^2 where N > 1M usually . ( check this post https://pkisensee.wordpress.com/2011/06/02/efficient-stl-insertion-tip-of-the-month/)

To count the elements meeting the predicate or do something else for each element without the creation of the result container you can use:

1. boost::function_output_iterator
// using C++11 lambda expression, in C++98 you can pass a function object
size_t counter = 0;
rtree.query(bgi::intersects(box),
            boost::make_function_output_iterator(
                [&](Value const&) {
                    counter++;
                }));
2. query iterator

size_t count = std::distance(tree.qbegin(intersects(box)), tree.qend());

Regards,
Adam

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry