包含 List(of String) Vb.net 是否需要哈希集
以下内容会
Dim stringlist As List(Of String)
Dim stringlisthas = stringlist.Contains("thing1")
比
Dim stringlist As List(Of String)
Dim stringlisthash As New HashSet(Of String)(stringlist)
Dim stringlisthas = stringlisthash.Contains("thing1")
Is a hashset need for contains 慢吗?
Would the following:
Dim stringlist As List(Of String)
Dim stringlisthas = stringlist.Contains("thing1")
be any slower than
Dim stringlist As List(Of String)
Dim stringlisthash As New HashSet(Of String)(stringlist)
Dim stringlisthas = stringlisthash.Contains("thing1")
Is a hashset needed for contains?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要吗?不。
大概。这取决于
List.Contains
的实现方式(可能是线性搜索)。我来回答一个你没有问过的问题。
这取决于。您必须对两者进行编码,对其进行分析,并查看它是否是应用程序中的瓶颈。如果不是,请坚持使用
List.Contains
。Needed? No.
Probably. It depends on how
List<T>.Contains
is implemented (its probably a linear search).I'll answer a question you didn't ask.
It depends. You have to code up both, profile it, and see if it's a bottleneck in your application. If it's not, just stick with
List<T>.Contains
.