什么.NET集合提供最快的搜索 [英] What .NET collection provides the fastest search
本文介绍了什么.NET集合提供最快的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有60k个项目需要根据20k的查找列表进行检查。是否有一个提供异常快速的集合对象(如 List
, HashTable
)包含)
方法?还是我要写我自己的?换句话说,是默认的 Contains()
方法只是扫描每个项目或使用更好的搜索算法。
I have 60k items that need to be checked against a 20k lookup list. Is there a collection object (like List
, HashTable
) that provides an exceptionly fast Contains()
method? Or will I have to write my own? In otherwords, is the default Contains()
method just scan each item or does it use a better search algorithm.
foreach (Record item in LargeCollection)
{
if (LookupCollection.Contains(item.Key))
{
// Do something
}
}
注意。查找列表已排序。
推荐答案
System.Collections.Generic.HashSet
这篇关于什么.NET集合提供最快的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文