I need to have a key with multiple values. What datastructure would you recommend?

前端 未结 7 1158
悲哀的现实
悲哀的现实 2021-02-07 10:53

I have an string array filled with words from a sentence.

words[0] = \"the\"
words[1] = \"dog\"
words[2] = \"jumped\"
words[3] = \"over\"
words[4] = \"the\"
word         


        
7条回答
  •  庸人自扰
    2021-02-07 11:11

    As two others pointed out, std::multimap can be your solution.

    Also consider std::tr1::unordered_multimap. It is available in VS 2008 seems to have it, GCC has it at least from version 4.3.

提交回复
热议问题