“multiset” & “multimap” - What's the point?

后端 未结 7 1683
孤城傲影
孤城傲影 2020-12-08 18:58

As the question states ... I don\'t get the point about multisets / multimaps.

So, what\'s the purpose?

7条回答
  •  粉色の甜心
    2020-12-08 19:36

    A multiset or multimap is simply for situations where there might be more than one of a particular item. For example, let's say you wanted to create an index for a book. You'd scan through the text, throw out all the really common meaningless words ("a", "an", "the", etc.) and then make a list of all the rest, and the place in the book where each occurred.

    Quite a few of the words will appear on more than one page, in which case you'll have multiple entries mapping from one word to different pages. One way to handle that would be a multimap from words to page numbers.

提交回复
热议问题