给我一个实用的情况下多集 [英] Give me a practical use-case of Multi-set
问题描述
我想知道一些实际的用例(如果他们不相关/绑定到任何编程语言,它会更好)。我可以关联集,列表和地图到实际的用例。
I would like to know a few practical use-cases (if they are not related/tied to any programming language it will be better).I can associate Sets, Lists and Maps to practical use cases.
例如,如果您想要一本书的词汇表,其中您想要的术语按字母顺序列出,并且位置/页面编号是该值,则可以使用集合TreeMap OrderedMap是一个地图)
For example if you wanted a glossary of a book where terms that you want are listed alphabetically and a location/page number is the value, you would use the collection TreeMap(OrderedMap which is a Map)
不知怎的,我不能将MultiSets与任何实用用例程序相关联。有人知道有任何用途吗?
Somehow, I can't associate MultiSets with any "practical" usecase. Does someone know of any uses?
http: //en.wikipedia.org/wiki/Multiset 不足够告诉我)
PS:如果你们认为这应该是community-wiki ed是好的。
PS: If you guys think this should be community-wiki'ed it is okay. The only reason I did not do it was "There is a clear objective way to answer this question".
推荐答案
很多应用程序。例如,想象一个购物车。它可以包含一个项目的多个实例 - 即2个cpu的,3个图形板等。因此它是一个多集。一个简单的实现是跟踪每个项目的数量 - 即保持信息2 cpu的,3个图形板等。
Lots of applications. For example, imagine a shopping cart. That can contain more than one instance of an item - i.e. 2 cpu's, 3 graphics boards, etc. So it is a Multi-set. One simple implementation is to also keep track of the number of items of each - i.e. keep around the info 2 cpu's, 3 graphics boards, etc.
我相信你可以想到很多其他应用程序。
I'm sure you can think of lots of other applications.
这篇关于给我一个实用的情况下多集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!