i really dont get it:
i am reading points, each holds 3 float values, out of a binary file. Saving this points in an unordered_map
therefore i try to create a key out of these 3 float values:
first intention: just use the exact bits as key:
unordered_map<string, vector<float>> points;
string vecToKey( float* a ) {
char bytes[12];
memcpy(bytes, a, 12);
return string(bytes);
}
the point is that i definitely want to eleminate same points this way but
in an example project reading about 21374 points the map result size = 10640 points
using following method as key creation results in the proper result of 10687 points
string vec3ToKey( float a[3] ) {
float a1[3];
a1[0] = a[0];
a1[1] = a[1];
a1[2] = a[2];
stringstream ss;
boost::archive::text_oarchive oa(ss);
oa << a1;
return ss.str();
}
the problem is the speed. second method needs about 16 seconds and first method just 1-2 seconds... i just cant explane myself why there even is a difference ...
i appreciate every idea :)