有没有多集的净任何实现的? [英] Are there any implementations of multiset for .Net?

查看:136
本文介绍了有没有多集的净任何实现的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个.NET实现一个多重的。谁能推荐一个好?

I'm looking for a .Net implementation of a multiset. Can anyone recommend a good one?

(一多集,或袋子,是一组可以有重复的值,并在其上​​可以做集合运算:交,差,等一个购物车的实例可以被看作是一个多集,因为你可以有多次出现同一产品的。)

(A multiset, or bag, is a set that can have duplicate values, and on which you can do set operations: intersection, difference, etc. A shopping cart for instance could be thought of as a multiset because you can have multiple occurrences of the same product.)

推荐答案

我不知道的,但是你可以使用词典的是,其中的价值是该项目的数量。而当项目添加第二次,你vould增加在字典的价值所在。

I do not know about one, however you could use a Dictionary for that, in which the value is the quantity of the item. And when the item is added for the second time, you vould increase the value for it in the dictionary.

这是另一种可能性是简单地使用的物品,在其中你可以把重复的列表。这可能是一个购物车一个更好的办法。

An other possibility would be to simply use a List of items, in which you could put duplicates. This might be a better approach for a shopping cart.

这篇关于有没有多集的净任何实现的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆