.NET Framework 3.5 is released! Among the new enhancements? System.Collections.Generic.HashedSet
It turns out no! Microsoft has chosen to not add an interface which matches this collections set based operations. There is no matching ISet interface which the new HashedSet implements. While some people will say "yeah but it still uses IEnumerable
The only thought I could come up with regarding why this obvious interface was left out is that if it is just an interface you can not guarantee that the collection behaves like a set. For example with a set you can not add the same item twice. If a custom collection were to implement said ISet and decided to let the Add method add the same item multiple times, what would stop them?
I suppose a set isn't something you can just define by an interface. Maybe I should let my emotions cool down prior to jumping over Microsoft for leaving out this interface. I guess I was just imagining the possibility of using NHibernate without having to add Iesi.Collections to my project. Then again, what would make me think that this would change, or change in a relevant time frame?
All that being said, I still wish they included the interface! After all there is an IDictionary which could theoretically be implemented in such a way that the custom collection could add the same key multiple times. If the Dictionary semantics can't be guaranteed by the already existing interface, then I say it would have been ok for such an interface to exist for the set.
--John Chapman
Thursday, November 29, 2007
Where Is System.Collections.Collections.Generic.ISet?
Posted by John Chapman at 5:23 PM
Labels: Visual Studio 2008
Subscribe to:
Post Comments (Atom)
2 comments:
Great read thhank you
Thank you very nice sharing.
Post a Comment