标准库中的哪些功能可以通过编程入侵更快地实现? [英] What are the functions in the standard library that can be implemented faster with programming hacks?

查看:120
本文介绍了标准库中的哪些功能可以通过编程入侵更快地实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近阅读了关于快速sqrt计算的一篇文章。因此,我决定要求SO社区及其专家帮助我找出,哪些STL算法或数学计算可以更快地实施编程黑客?

I have recently read an article about fast sqrt calculation. Therefore, I have decided to ask SO community and its experts to help me find out, which STL algorithms or mathematical calculations can be implemented faster with programming hacks?

如果您可以提供示例或链接,这将是非常好的。

It would be great if you can give examples or links.


推荐答案

< algorithm> 中的几个算法可以优化为 vector< bool> :: [const_] iterator 。这些包括:

Several of the algorithms in <algorithm> can be optimized for vector<bool>::[const_]iterator. These include:

find
count
fill
fill_n
copy
copy_backward
move // C++0x
move_backward  // C++0x
swap_ranges
rotate
equal

我可能错过了一些。但是所有上述算法可以被优化为一次处理多个位,而不是一次只处理一个位(如同一个朴素的实现)。

I've probably missed some. But all of the above algorithms can be optimized to work on many bits at a time instead of just one bit at a time (as would a naive implementation).

这是我怀疑大多数STL实现中缺少一个优化。它不是从这一个缺少:

This is an optimization that I suspect is sorely missing from most STL implementations. It is not missing from this one:

http:// libcxx .llvm.org /

这篇关于标准库中的哪些功能可以通过编程入侵更快地实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆