带有自定义IEqualityComparer的Distinct()方法的Big O [英] The Big O of Distinct() method with a Custom IEqualityComparer
本文介绍了带有自定义IEqualityComparer的Distinct()方法的Big O的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都知道使用自定义IEqualityComparer
的Distinct()
方法中使用的算法的大O吗?
Anyone knows the Big O of the algorithm used in the Distinct()
method, with a custom IEqualityComparer
?
推荐答案
There's an equal question here on SO about "What guarantees are there on the run-time complexity (Big-O) of LINQ methods?"
请参阅答案中有关非重复的这一部分:
See this section in the answer about distinct:
与众不同,请加入,我相信 还有集合聚合方法 (联合,相交和除外)使用 散列,所以它们应该接近 O(N)代替O(N²).
Distinct, GroupBy Join, and I believe also the set-aggregation methods (Union, Intersect and Except) use hashing, so they should be close to O(N) instead of O(N²).
这篇关于带有自定义IEqualityComparer的Distinct()方法的Big O的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文