I need to create std::map<cv::Point, double>
. cv::Point
is a type of a point from OpenCV library. It has fields like: x
and y
.
cv::Point
does not have <
operator of course. Do you have any idea how to define it to have optimal access to element in std::map
?
In other words. I have for example 20000 points. I need quite fast access to every point.
For example:
std::map<cv::Point, double> myMap;
Point p(10, 234);
int value = 777;
myMap[p] = value; // I need this operation quite fast so I decided to use std::map
But cv::Point does not have <
operator. I can prepare <
operator like (it comparing for example only x coordinate):
bool operator<(const cv::Point a, const cv::Point b)
{
return a.x < a.x;
}
But I guess it is not good operator. Many points has the same value of x.
How to prepare efficient operator in this case?