最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

带有自定义IEqualityComparer的Distinct()方法的Big O

SEO心得admin71浏览0评论
本文介绍了带有自定义IEqualityComparer的Distinct()方法的Big O的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

任何人都知道使用自定义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²).

发布评论

评论列表(0)

  1. 暂无评论