//A class that has an initialization lock so that when the lock is activated, any further gets that are missing items in it will report themselves for easier debugging detection.
//A class that has an initialization lock so that when the lock is activated, any further gets that are missing items in it will report themselves for easier debugging detection.
//This unordered map should return items inserted in order. Therefore internally, it's hosted as a vector. As such, if an item is added to this map it's possible the refernce becomes stale when another item is added due to a vector expanding. BEWARE!
template<typenameT,typenameO>
template<typenameT,typenameO>
classsafeunorderedmap{
classsafeunorderedmap{
std::unordered_map<T,O>map;
std::unordered_map<T,int>map;
std::vector<O>items;
boolinitialized=false;
boolinitialized=false;
public:
public:
O&operator[](Tkey){
O&operator[](Tkey){
@ -62,18 +64,19 @@ public:
}
}
if(!initialized){
if(!initialized){
size_toriginalSize=map.size();
size_toriginalSize=map.size();
O&val=map[key];
map[key]=items.size();
if(originalSize==map.size()){
if(originalSize==map.size()){
std::cout<<"WARNING! A previously set value has been overwritten! Key: "<<key<<std::endl;
std::cout<<"WARNING! A previously set value has been overwritten! Key: "<<key<<std::endl;