Original Post
I'm having a bit of trouble here: I'd like to create a hashtable (std::map), mapping a bunch of points (meaning a structure tPoint3Df with 3 coordinates, x, y and z) to some arbitrary object pointer, in my case a vector object. I've worked a lot with maps before, taking object pointers, ints, float, etc. for my map keys, but never a structure of my own. My typedef looks as follows: typedef map pointVectorMap; here's the question: how must my point3DfLess function be implemented? I currently have an implementation, working on the length of the point (absolute value of square root of square coordinates), which I assume incorrect because the find() function does not work properly. In my case, it seems like the vector I get returned is independent of the key-point's z value. I assume that is because the length is not enough of a property to say one point is "less" than another, makes sense. I just can't figure out another solution at the moment. my less function is currently implemented as follows struct point3DfLess { // functor for operator bool operator()(const tPoint3Df& leftPoint, const tPoint3Df& rightPoint) const { // apply operator to operands double leftLength = sqrt(leftPoint.x * leftPoint.x + leftPoint.y * leftPoint.y + leftPoint.z * leftPoint.z); double rightLength = sqrt(rightPoint.x * rightPoint.x + rightPoint.y * rightPoint.y + rightPoint.z * rightPoint.z); return ( (leftLength < rightLength) || (leftLength == rightLength && leftPoint.x < rightPoint.x) || (leftLength == rightLength && leftPoint.y < rightPoint.y && leftPoint.z < rightPoint.z)); } }; Any help would be appreciated, thanks in advance