有没有多集的净任何实现的?有多

2023-09-03 01:20:27 作者:面目全非

我在寻找一个.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.