泛型编程(GP)和C++标准模板库(STL)

Generic Programming(GP)泛型编程,就是使用template(模板)为主要工具来编写程序

level0:使用C++标准库
level1:认识C++标准库
level2: 良好使用C++标准库
level3: 扩充C++标准库

C++ Standard Library
C++标准库,编译器带的,可以看到source code
至于Standard Template Library ->STL 标准模板库
可以说标准库>STL,也即标准库包括标准模板库,标准库里面75%左右都是STL,STL有六大部件
你只要手上有编译器,那么你已经带着了 C++ Standard Library
标准库以header files形式呈现

STL六大部件(components)
容器(Containers)
分配器(Allocators)
算法(Algorithms)
迭代器(Iterators)
适配器(Adapters)
防函式(Functors)

容器之分类与各种测试(二)
这一节主要比较了C的标准库中的find函数
和STL中的先sort后binsearch所用时间的比较,
结果是find()所用时间远小于后面一种方法
结论:不要以为,先sort后binsearch很快,实际上可能sort本身就很慢

posted @ 2023-05-23 18:56  光辉233  阅读(37)  评论(0)    收藏  举报