Changeset 10988 for code/branches
- Timestamp:
- Dec 28, 2015, 11:22:21 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/core/class
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.cc
r10916 r10988 60 60 61 61 this->identifiers_.insert(identifier); 62 this->identifierByTypeIndex_[identifier->getTypeInfo()] = identifier; 62 63 this->identifierByString_[identifier->getName()] = identifier; 63 64 this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; … … 71 72 { 72 73 this->identifiers_.erase(identifier); 74 this->identifierByTypeIndex_.erase(identifier->getTypeInfo()); 73 75 this->identifierByString_.erase(identifier->getName()); 74 76 this->identifierByLowercaseString_.erase(getLowercase(identifier->getName())); … … 258 260 Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo) 259 261 { 260 // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)261 for (Identifier* identifer : this->identifiers_)262 if (identifer->getTypeInfo() == typeInfo)263 return identifer;264 return nullptr;262 auto it = this->identifierByTypeIndex_.find(typeInfo); 263 if (it != this->identifierByTypeIndex_.end()) 264 return it->second; 265 else 266 return nullptr; 265 267 } 266 268 -
code/branches/cpp11_v2/src/libraries/core/class/IdentifierManager.h
r10769 r10988 37 37 #include "core/CorePrereqs.h" 38 38 39 #include <typeindex> 39 40 #include <map> 41 #include <unordered_map> 40 42 #include <set> 41 43 #include <list> … … 102 104 { hierarchyCreatingCounter_s--; } 103 105 104 std::set<Identifier*> identifiers_; //!< All identifiers. This is only used internally. 105 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 106 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 107 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 106 std::set<Identifier*> identifiers_; //!< All identifiers. This is only used internally. 107 std::unordered_map<std::type_index, Identifier*> identifierByTypeIndex_; //!< Map that stores all Identifiers with their type_index. 108 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 109 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 110 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 108 111 109 112 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
Note: See TracChangeset
for help on using the changeset viewer.