I've a map that stores, string and a set of doubles as follows.
typedef std::map<std::string, std::set<double> > exprType;
typedef std::map<std::string, std::set<double> >::iterator exprIter;
exprType exPricesData;
std::vector<double> lastprice;
std::string exchange;
I need a way to insert prices for a given key and wrote the following piece of code.
std::set<double> prices;
double temp = lastprice[0]; // An array of values comes as a parameter
prices.insert(temp); // Creating a temp. set
std::pair<exprIter,bool> locIter = exPricesData.insert(
std::pair<std::string, std::set<double> >(exchange, prices));
for ( int i = 1; i < lastprice.size() ; ++i )
{
locIter.first->second.insert(lastprice[i]);
}
I'm wondering, is there a way to improve especially, the first part, which creates a temp set.