I have been given a mutlimap
typedef std::multimap<std::string, size_t, StringLenCmp> wordDictType;
in a class and I need to design a function that will insert a word and word length into the multi map. I know to traditionally insert into multimap, I would do
mmap["one"] = 1;
or
mmap.insert(make_pair("one", 1));
but I don't know what StringLenCmp is. It is the class,
class StringLenCmp {
public:
StringLenCmp() = default;
// sort by length first, and then alphabetically
bool operator()(const std::string& a, const std::string& b) const {
return (a.size() < b.size()) || (a.size() == b.size() && a < b);
}
private:
// no data
};
but the problem is, I have no idea what all this means.
Can someone help me decipher all this.