/* In my first pass at a solution, I create a map from the items. I convert each string to upper-case, and then store that string in the map as a key, with the value being the original string. I print it out at the end. */ #include "glossary.hpp" #include #include #include #include using namespace std; vector Glossary::buildGlossary(const vector &items) { size_t i, j; string s; map g; map ::iterator git; vector rv; for (i = 0; i < items.size(); i++) { s = items[i]; // s is the upper-case string. for (j = 0; j < s.size(); j++) { if (s[j] >= 'a' && s[j] <= 'z') s[j] += ('A'-'a'); } g[s] = items[i]; // This puts s and items[i] into the map. } for (git = g.begin(); git != g.end(); git++) { // Print the map cout << git->first << " " << git->second << endl; } return rv; }