问题描述
我的一个处理从Java移动到.NET最大的问题是事实,没有.NET中设置接口。我知道有图书馆,我可以去下载,但什么是没有这样的勇气内置的原因吗?有地图(词典)和列表,但为什么不是一套?
One of my biggest issues dealing with a move from Java to .Net is the fact that there isn't a Set interface in .Net. I know there are libraries I could go and download but what is the reason for not having it built in? There are Maps (Dictionary) and Lists but why not a Set?
修改:我要澄清的是,不是每个人都使用的.Net 3.5还没有 - 所以我或多或少提及旧版本的.Net的
Edit: I should clarify that not everyone uses .Net 3.5 yet -- so I'm more or less referring to older versions of .Net
推荐答案
我觉得它只是一个遗漏的BCL作家。 .NET 3.5拥有 HashSet的类;对于早期版本,我建议封装字典< T,对象&gt ;,在值字段为空,复制O(1)添加,删除,查找时间
I think it's simply an omission by the BCL writers. .NET 3.5 has a HashSet class; for earlier versions, I recommend wrapping a Dictionary<T, object>, with nulls in the value field, to replicate O(1) add, remove and lookup time.
这篇关于为什么不净有一组数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!