简体   繁体   English

C ++算法/增强库是否具有基数排序?

[英]Does C++ Algorithm/Boost Lib have Radix Sort?

I want to sort integers and I know radix sort is supposed to be awesome for it. 我想对整数进行排序,并且我知道基数排序对此非常有用。 Any library implementation for this sort? 任何此类的库实现?

Depends on how strictly you define radix sort , since Boost 1.58.0 includes Spreadsort , which is a hybrid sorting algorithm that heuristically mixes bucket and comparison sorting. 取决于您对基数排序的定义严格程度,因为Boost 1.58.0包含Spreadsort ,这是一种混合排序算法,可启发式地混合存储桶和比较排序。

For sorting integers and with no requirement for worst-case Θ(n) efficiency, Spreadsort should satisfy you. 对于排序整数并且不要求最坏情况下的Θ(n)效率,Spreadsort应该会让您满意。

For argument's sake, you can also take a look at my implementation of LSD radix sort , which is fairly inefficient with memory but occasionally faster than Spreadsort. 出于争论的考虑,您还可以看一下我对LSD基数排序的实现 ,该实现在内存方面效率低下,但有时比Spreadsort快。 You only require the radix_sort branch but I've linked to the speed_test branch because it has the readme. 您只需要radix_sort分支,但是我已经链接到speed_test分支,因为它具有自述文件。

The more actual answer is Yes since 1.58 it does: 从1.58开始,更实际的答案是

It has something known as SpreadSort and will "magically" detect optimized paths for types like std::string , or floating point numbers that can be treated as byte arrays. 它有一个称为SpreadSort的东西,它将“神奇地”检测类型的优化路径,例如std::string或可以视为字节数组的浮点数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM