为什么没有.Net有一个Set数据结构? [英] Why doesn't .Net have a Set data structure?

查看:99
本文介绍了为什么没有.Net有一个Set数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最大的一个问题是处理从Java到.Net的事情,在.Net中没有一个Set接口。我知道有可以下载的图书馆,但没有内置的原因是什么?有地图(字典)和列表,但为什么不设置?

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,对象>,以复制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.

这篇关于为什么没有.Net有一个Set数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆