Are there any implementations of multiset for .Net?

后端 未结 3 1238
梦谈多话
梦谈多话 2020-12-18 18:11

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

3条回答
  •  一生所求
    2020-12-18 18:21

    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.

提交回复
热议问题