I have a 3-component vector structure called Vector3 with 3 int , representing X, Y and Z. For each three-dimensional point (I have more or less than 200-300 different three-dimensional points) I have a string .
What I want to do is to have a data structure that checks for the presence of a string for this location. I wanted to use std::map and I made this code without good results:
The error is that it simply starts the else part once and continues to return the same string again and again.
My Vector3 class is the one that Ogre3D has: http://www.ogre3d.org/docs/api/html/classOgre_1_1Vector3.html
String WorldGenerator::createPlatformBorder(Vector3 size) { static std::map<Vector3, String> generatedBorders; if (generatedBorders.find(size) != generatedBorders.end()) { return generatedBorders[size]; } else { String blockName = requestNewPlatformBorderName(); generatedBorders.insert(std::pair<Vector3, String>(size, blockName));
Could you please help me?
Please note that the requestNewPlatformBorderName() function works fine, so there is no error. Here is the code for it:
String requestNewPlatformBorderName() { static int counter = 0; return StringConverter::toString(++counter) + "-platform-border"; }
source share