Yes, but do this only once up front, not every time you access a matrix element. Of course, if the strings are being generated dynamically and handed to you, you can't do that. But if you're given a...
Type: Posts; User: brewbuck
Yes, but do this only once up front, not every time you access a matrix element. Of course, if the strings are being generated dynamically and handed to you, you can't do that. But if you're given a...
std::map< string, int > to map from strings to row/column indices. You then look up via:
double value = data[ rowMap[ rowName ] * colMap.size() + colMap[ colName ] ];
But if "efficiency"...