Subject: CGAL users discussion list
List archive
- From: Ross Hemsley <>
- To:
- Subject: [cgal-discuss] Applying a functor to CGAL iterator ranges.
- Date: Tue, 5 Feb 2013 17:19:26 +0100 (CET)
I am writing a class with a series of functions that work by applying
functors to an iterator range over a set of elements.
Example:
template< typename Iterator, typename Functor >
double mean(Iterator begin, Iterator end, Functor f)
{
double sum = 0;
int count = 0 ;
for (Iterator i=begin; i!=end; ++i)
{
sum += f(*i);
++count;
}
}
However, I now want to use the "Triangulation_2::finite_vertices_iterator"
as the iterator, and I want to apply a functor that requires access to the
vertex_handle. - This is a problem because the algorithm above dereferences
the iterator and gives me a plain vertex: The problem is that dereferencing
the iterator that CGAL gives us causes us to lose information.
I'm looking for a solution that keeps the same input parameters (an iterator
with '::value_type' that corresponds to the argument of the functor).
But may work differently 'under the hood' - i.e. we have a special
helper function "apply(f, x)" that applies a function to an
iterator. I tried to use some dirty 'template magick' tricks to do this but
the ideas I had require features that are only reliably available in C++11.
Any ideas?
- [cgal-discuss] Applying a functor to CGAL iterator ranges., Ross Hemsley, 02/05/2013
- Re: [cgal-discuss] Applying a functor to CGAL iterator ranges., Cody Rose, 02/05/2013
- [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., RossH, 02/05/2013
- Re: [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., Cody Rose, 02/05/2013
- [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., RossH, 02/06/2013
- Re: [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., Cody Rose, 02/05/2013
- [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., RossH, 02/05/2013
- Re: [cgal-discuss] Applying a functor to CGAL iterator ranges., Philipp Moeller, 02/05/2013
- [cgal-discuss] Re: Applying a functor to CGAL iterator ranges., RossH, 02/06/2013
- Re: [cgal-discuss] Applying a functor to CGAL iterator ranges., Cody Rose, 02/05/2013
Archive powered by MHonArc 2.6.18.