Boost C++ 库

……是全球最受推崇、设计最精良的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu《C++ 编码标准》

Boost 算法库 - Boost C++ 函数库
Next

Boost 算法库

Marshall Clow

根据 Boost 软件许可证版本 1.0 发布。(参见随附文件 LICENSE_1_0.txt 或在 https://boost.ac.cn/LICENSE_1_0.txt 复制)

目录

描述和原理
搜索算法
Boyer-Moore 搜索
Boyer-Moore-Horspool 搜索
Knuth-Morris-Pratt 搜索
C++11 算法
all_of
any_of
none_of
one_of
is_sorted
is_partitioned
is_permutation
partition_point
partition_copy
copy_if
copy_n
iota
C++14 算法
equal
mismatch
C++17 算法
for_each_n
transform_inclusive_scan
transform_exclusive_scan
Copy 变体
copy_until
copy_while
copy_if_until
copy_if_while
其他算法
none_of_equal
one_of_equal
is_decreasing
is_increasing
is_strictly_decreasing
is_strictly_increasing
clamp
clamp_range
find_not
find_backward
find_not_backward
find_if_backward
find_if_not
find_if_not_backward
gather
hex
unhex
hex_lower
is_palindrome
is_partitioned_until
apply_reverse_permutation
apply_permutation
iota_n
power
尚未文档化的 C++17 算法
尚未文档化的其他算法
参考
头文件 <boost/algorithm/algorithm.hpp>
头文件 <boost/algorithm/apply_permutation.hpp>
头文件 <boost/algorithm/clamp.hpp>
头文件 <boost/algorithm/cxx11/all_of.hpp>
头文件 <boost/algorithm/cxx11/any_of.hpp>
头文件 <boost/algorithm/cxx11/copy_if.hpp>
头文件 <boost/algorithm/cxx11/copy_n.hpp>
头文件 <boost/algorithm/cxx11/find_if_not.hpp>
头文件 <boost/algorithm/cxx11/iota.hpp>
头文件 <boost/algorithm/cxx11/is_partitioned.hpp>
头文件 <boost/algorithm/cxx11/is_permutation.hpp>
头文件 <boost/algorithm/cxx14/is_permutation.hpp>
头文件 <boost/algorithm/cxx11/is_sorted.hpp>
头文件 <boost/algorithm/cxx11/none_of.hpp>
头文件 <boost/algorithm/cxx11/one_of.hpp>
头文件 <boost/algorithm/cxx11/partition_copy.hpp>
头文件 <boost/algorithm/cxx11/partition_point.hpp>
头文件 <boost/algorithm/cxx14/equal.hpp>
头文件 <boost/algorithm/cxx14/mismatch.hpp>
头文件 <boost/algorithm/cxx17/exclusive_scan.hpp>
头文件 <boost/algorithm/cxx17/for_each_n.hpp>
头文件 <boost/algorithm/cxx17/inclusive_scan.hpp>
头文件 <boost/algorithm/cxx17/reduce.hpp>
头文件 <boost/algorithm/cxx17/transform_exclusive_scan.hpp>
头文件 <boost/algorithm/cxx17/transform_inclusive_scan.hpp>
头文件 <boost/algorithm/cxx17/transform_reduce.hpp>
头文件 <boost/algorithm/find_backward.hpp>
头文件 <boost/algorithm/find_not.hpp>
头文件 <boost/algorithm/gather.hpp>
头文件 <boost/algorithm/hex.hpp>
头文件 <boost/algorithm/is_clamped.hpp>
头文件 <boost/algorithm/is_palindrome.hpp>
头文件 <boost/algorithm/is_partitioned_until.hpp>
头文件 <boost/algorithm/minmax.hpp>
头文件 <boost/algorithm/minmax_element.hpp>
头文件 <boost/algorithm/searching/boyer_moore.hpp>
头文件 <boost/algorithm/searching/boyer_moore_horspool.hpp>
头文件 <boost/algorithm/searching/knuth_morris_pratt.hpp>
头文件 <boost/algorithm/sort_subrange.hpp>
头文件 <boost/algorithm/string.hpp>
头文件 <boost/algorithm/string_regex.hpp>

Boost.Algorithm 是一系列通用算法的集合。虽然 Boost 包含许多数据结构库,但并没有一个专门用于通用算法的库。即使这些算法通常很有用,但许多算法往往因为“太小”而不被认为是 Boost 的一部分。

例如,实现 Boyer-Moore 搜索可能需要开发人员花费一周左右的时间,包括测试用例和文档。然而,安排一次评审以将该代码包含到 Boost 中可能需要数月时间,并且会遇到阻力,因为它“太小了”。尽管如此,一个经过测试、评审、文档化的算法库可以大大简化开发人员的生活,这也是本库的目的。

未来计划

我将征集其他开发人员的投稿,并查阅文献以包含现有算法。例如,Adobe Source Library 包含许多有用的算法,这些算法已经有了文档和测试用例。Knuth 的《计算机程序设计艺术》也充满了算法描述。

我的目标是定期进行算法评审,类似于 Boost 库的评审流程,但处理的代码量更小。

依赖关系

Boost.Algorithm 使用 Boost.Range、Boost.Assert、Boost.Array、Boost.TypeTraits 和 Boost.StaticAssert。

致谢

感谢所有评审过本库并提出改进建议的人。特别是 Steven Watanabe 和 Sean Parent 提供了极大的帮助。


Next