任何人都知道使用自定义IEqualityComparer的Distinct()方法中使用的算法的大O吗?
Anyone knows the Big O of the algorithm used in the Distinct() method, with a custom IEqualityComparer?
推荐答案SO上有一个关于" LINQ方法的运行时复杂度(Big-O)有什么保证?"
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²).