I have the following:
class SpritesheetManager{
std::unordered_map<std::string,std::unordered_set<std::string>> _loadedFiles;
void addFileToFileListForSheet(std::string sheetprefix,std::string filename);
}
When adding files I do this:
void SpritesheetManager::addFileToFileListForSheet(std::string sheetprefix,std::string filename){
bool containsKey = (_loadedFiles.find(sheetprefix)!= _loadedFiles.end());
std::unordered_set<std::string> values;
if(!containsKey){
_loadedFiles[sheetprefix] = values;
}
_loadedFiles[sheetprefix].insert(filename);
}
Is there a better way to do this?
Aucun commentaire:
Enregistrer un commentaire