K
kimt
Hello, I am currently writing an application that involves many (>
1000) points on a (x,y) plane. I am using a struct to contain the
position information, and I have the structs contained in a STL
vector. Given a target coordinate (x,y)_t, I would like to be able to
cycle through the vector of points in order to obtain the closest
point. What would be the most efficient way to implement this?
I have considered keeping the vector sorted by the coordinates, say,
by the x-coordinate and the y-coordinate and to "home-in" on the point
by two successive filters. However, my memory of the STL is not so
great and I would very much appreciate some pointers in implementing
this idea.
Furthermore, it seems like this approach may not always yield the
point that is closest to the point.
Thank you in advance
1000) points on a (x,y) plane. I am using a struct to contain the
position information, and I have the structs contained in a STL
vector. Given a target coordinate (x,y)_t, I would like to be able to
cycle through the vector of points in order to obtain the closest
point. What would be the most efficient way to implement this?
I have considered keeping the vector sorted by the coordinates, say,
by the x-coordinate and the y-coordinate and to "home-in" on the point
by two successive filters. However, my memory of the STL is not so
great and I would very much appreciate some pointers in implementing
this idea.
Furthermore, it seems like this approach may not always yield the
point that is closest to the point.
Thank you in advance