What is the .net equivalent of a java hashbag collection, a collection that stores like items only once but also stores the number of occurrences of the items?
Asked
Active
Viewed 290 times
1
-
I don't think there is a .net equivalent. – paparazzo Jan 17 '15 at 20:51
-
1Implementing it using a `Dictionary
` shouldn't be hard. – CodesInChaos Jan 17 '15 at 21:11 -
@CodesInChaos - Thanks, implementing it using `Dictionary
` wasn't too hard and works well for what I need. – roidy Jan 18 '15 at 15:21
1 Answers
0
See also: Duplicate keys in .NET dictionaries? Another common name for bag is multiset, see also: Are there any implementations of multiset for .Net?
Via those links I found the Wintellect's Power Collections bag implementation. From its source:
Bag<T> is a collection that contains items of type T.
Unlike a Set, duplicate items (items that compare equal to each other) are allowed in an
Bag.
Not a .net user myself so I don't know if this library is too old to be useful. Hopefully it helps!