Microsoft 的 STL::list::sort() 使用哪种排序算法?

发布于 2024-08-10 10:39:03 字数 356 浏览 2 评论 0原文

注意:我不小心发布了这个问题,但没有指定我正在使用哪种 STL 实现,并且我觉得它无法真正更新,因为它会使大部分答案变得过时。

因此,正确的问题是 - 下面的代码中使用哪种排序算法,假设我正在使用 Microsoft Visual C++ 的 STL 库?:

list<int> mylist;

// ..insert a million values

mylist.sort();

Note: I accidentally posted this question without specifying which STL implementation I was using, and I felt it can't really be updated since it would render most of its answers obsolete.

So, the correct question goes - which sorting algorithm is used in the below code, assuming I'm using the STL library of Microsoft Visual C++?:

list<int> mylist;

// ..insert a million values

mylist.sort();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼泪都笑了 2024-08-17 10:39:03

为了让您不必依赖二手信息,排序代码位于 list 标头中 - 大约 35 行。

似乎是一种修改后的迭代(非递归)合并排序,最多有 25 个容器(我不知道这种合并排序变体是否有特定的名称)。

Just so you don't have to rely on second hand information, the the sort code is right in the list header - it's about 35 lines.

Appears to be a modified iterative (non-recursive) merge sort with up to 25 bins (I don't know if there's a particular name for this variant of merge sort).

爱冒险 2024-08-17 10:39:03

至少在最近的版本(例如VC++ 9.0/VS 2008)中,MS VC++ 使用合并排序。

At least in recent versions (e.g. VC++ 9.0/VS 2008) MS VC++ uses a merge-sort.

梦巷 2024-08-17 10:39:03

MS VC6 附带的 STL 是 PJ Plauger 版本的库 (Dinkumware),它在 std::list<>::sort() 中使用合并排序。我不知道 MS 软件包的更高版本。

STL that came with MS VC6 was the P. J. Plauger's version of the library (Dinkumware) and it used merge-sort in std::list<>::sort(). I dont know about later versions of MS's package.

趁年轻赶紧闹 2024-08-17 10:39:03

据我所知,它是 Introsoft: http://en.wikipedia.org/wiki/Introsort

To my knowledge it is Introsoft: http://en.wikipedia.org/wiki/Introsort

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文