什么.NET集合提供最快的搜索 [英] What .NET collection provides the fastest search

查看:179
本文介绍了什么.NET集合提供最快的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有60K项需要与一个20K查找列表检查。是否有一个集合对象(如列表的HashTable ),它提供exceptionly快包含( )的方法?或者将我必须写我自己? 。换句话说,是默认的包含()方法只扫描每个项目或不会使用更好的搜索算法。

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
    }
}

注意。查找列表已经排序。

Note. The lookup list is already sorted.

推荐答案

<一个href="http://msdn.microsoft.com/en-us/library/bb359438.aspx"><$c$c>System.Collections.Generic.HashSet

这篇关于什么.NET集合提供最快的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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