A
Aaron Walker
I want a std::map<std::string, std::string> but I don't want it sorted by keys.
I've been able to simulate this with a vector of pairs and operator[].
class umap : public std::vector<std:air<std::string, std::string > >
{
public:
std::string &operator[] (std::string s)
{
for (iterator i = begin() ; i != end() ; ++i)
if (i->first == s)
return i->second;
/* we got this far, so key must not exist */
push_back(std::make_pair(s, ""));
return back().second;
}
}
Not sure if this is the optimal way to go about it. Any suggestions?
I've been able to simulate this with a vector of pairs and operator[].
class umap : public std::vector<std:air<std::string, std::string > >
{
public:
std::string &operator[] (std::string s)
{
for (iterator i = begin() ; i != end() ; ++i)
if (i->first == s)
return i->second;
/* we got this far, so key must not exist */
push_back(std::make_pair(s, ""));
return back().second;
}
}
Not sure if this is the optimal way to go about it. Any suggestions?