I have a class Vertex
and I want to iterate on its neighbors in particulars ways, like this for example :
Vertex my_v;
for(const Vertex& v : my_v.get_neighbors_closer_than(10.0)
/* Some code on v*/
// And like this
for(const Vertex& v : my_v.get_neighbors_by_trigonometric_order()
/* Some code on v*/
For this, I created custom containers and iterators which iterate the way I want. Then, I need to create an inheritate class DlnVertex : public Vertex
which have most of the time the same behiavour about iterating functions. Thus, I would like to write inside my DlnVertex
class:
DlnVertex my_dv;
for(const DlnVertex& dv : my_dv.get_neighbors_closer_than(10.0))
/* Some code on dv*/
for(const DlnVertex& dv : get_neighbors_by_trigonometric_order())
/* Some code on dv*/
My custom iterator returns a Vertex&
, and I need in my class DlnVertex
to use DlnVertex
properties, and I don't know how to avoid re-writing an iterator for my inheritate class because it would have the same behiavour. Is there any advice, patterns, or code examples which can help me ?