在查找,单身,首先,其中之一是最快的? [英] Among Find, Single, First, which one is the fastest?
本文介绍了在查找,单身,首先,其中之一是最快的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望尽量减少检索的列表的单个独特元件所需要的时间。
哪一个是中最快的方法查找
,单
和首页
?
注意,搜索键是一个唯一的ID。
I want to minimize the time needed to retrieve a single unique element from a list.
Which one is the fastest method among Find
, Single
and First
?
Note that the searching key is a unique id.
推荐答案
的最快的(对于大集)将让他们键控反对词典< TKEY的,TValue方式>
和使用
The fastest (for a large set) would be to have them keyed against a Dictionary<TKey,TValue>
and use that.
单
和首先
做不同的事情; 单
总是遍历整个集合,即使它发现它在列表的开始,所以首先
通常会是比单更快
,因为它短路。
Single
and First
do different things; Single
always iterates the entire set, even if it finds it at the start of the list, so First
would usually be quicker than Single
since it short-circuits.
这篇关于在查找,单身,首先,其中之一是最快的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文