没有合适的资源?快使用搜索试试~ 我知道了~
首页CSTL参考文档,C下的STL
资源详情
资源评论
资源推荐
Table of Contents
1.libcstl 简介...........................................................................................................................................................5
1.1.容器和算法..................................................................................................................................................5
1.2.迭代器..........................................................................................................................................................5
1.3.libcstl 其他组成部分...................................................................................................................................5
2.怎样使用这篇文档.............................................................................................................................................6
3.容器......................................................................................................................................................................7
3.1.序列容器......................................................................................................................................................7
3.1.1.vector_t.................................................................................................................................................7
3.1.2.deque_t..................................................................................................................................................9
3.1.3.list_t.....................................................................................................................................................11
3.1.4.slist_t...................................................................................................................................................13
3.2.关联容器....................................................................................................................................................16
3.2.1.set_t.....................................................................................................................................................16
3.2.2.multiset_t.............................................................................................................................................17
3.2.3.map_t...................................................................................................................................................19
3.2.4.multimap_t..........................................................................................................................................21
3.2.5.hash_set_t............................................................................................................................................23
3.2.6.hash_multiset_t...................................................................................................................................25
3.2.7.hash_map_t.........................................................................................................................................27
3.2.8.hash_multimap_t.................................................................................................................................29
3.3.字符串........................................................................................................................................................31
3.3.1.string_t................................................................................................................................................31
3.4.容器适配器................................................................................................................................................37
3.4.1.stack_t.................................................................................................................................................37
3.4.2.queue_t................................................................................................................................................38
3.4.3.priority_queue_t..................................................................................................................................39
4.迭代器................................................................................................................................................................41
5.算法....................................................................................................................................................................42
5.1.非质变算法................................................................................................................................................42
5.1.1.algo_for_each......................................................................................................................................42
5.1.2.algo_find algo_find_if.....................................................................................................................42
5.1.3.algo_adjacent_find algo_adjacent_find_if.......................................................................................42
5.1.4.algo_find_first_of algo_find_first_if...............................................................................................43
5.1.5.algo_count algo_count_if.................................................................................................................43
5.1.6.algo_mismatch algo_mismatch_if...................................................................................................43
5.1.7.algo_equal algo_equal_if.................................................................................................................43
5.1.8.algo_search algo_search_if..............................................................................................................44
5.1.9.algo_search_n algo_search_n_if......................................................................................................44
5.1.10.algo_search_end algo_search_end_if algo_find_end algo_find_end_if.................................44
5.2.质变算法....................................................................................................................................................45
5.2.1.algo_copy............................................................................................................................................45
5.2.2.algo_copy_n........................................................................................................................................45
5.2.3.algo_copy_backward..........................................................................................................................46
5.2.4.algo_swap algo_iter_swap...............................................................................................................46
5.2.5.algo_swap_ranges...............................................................................................................................46
5.2.6.algo_transform algo_transform_binary...........................................................................................46
5.2.7.algo_replace algo_replace_if algo_replace_copy algo_replace_copy_if..................................47
5.2.8.algo_fill algo_fill_n.........................................................................................................................47
5.2.9.algo_generate algo_generate_n........................................................................................................48
5.2.10.algo_remove algo_remove_if algo_remove_copy algo_remove_copy_if...............................48
5.2.11.algo_unique algo_unique_if algo_unique_copy algo_unique_copy_if...................................48
5.2.12.algo_reverse algo_reverse_copy....................................................................................................49
5.2.13.algo_rotate algo_rotate_copy.........................................................................................................49
5.2.14.algo_random_shuffle algo_random_shuffle_if..............................................................................50
5.2.15.algo_random_sample algo_random_sample_if algo_random_sample_n
algo_random_sample_n_if...........................................................................................................................50
5.2.16.algo_partition algo_stable_partition..............................................................................................50
5.3.排序算法....................................................................................................................................................51
5.3.1.algo_sort algo_sort_if algo_stable_sort algo_stable_sort_if algo_is_sorted
algo_is_sorted_if..........................................................................................................................................51
5.3.2.algo_partial_sort algo_partial_sort_if algo_parital_sort_copy algo_partial_sort_copy_if........51
5.3.3.algo_nth_element algo_nth_element_if...........................................................................................52
5.3.4.algo_lower_bound algo_lower_bound_if........................................................................................52
5.3.5.algo_upper_bound algo_upper_bound_if........................................................................................53
5.3.6.algo_equal_range algo_equal_range_if...........................................................................................53
5.3.7.algo_binary_search algo_binary_search_if.....................................................................................53
5.3.8.algo_merge algo_merge_if..............................................................................................................54
5.3.9.algo_inplace_merge algo_inplace_merge_if...................................................................................54
5.3.10.algo_includes algo_includes_if......................................................................................................54
5.3.11.algo_set_union algo_set_union_if.................................................................................................55
5.3.12.algo_set_intersection algo_set_intersection_if..............................................................................55
5.3.13.algo_set_difference algo_set_difference_if...................................................................................56
5.3.14.algo_set_symmetric_difference algo_set_symmetric_difference_if.............................................56
5.3.15.algo_push_heap algo_push_heap_if..............................................................................................56
5.3.16.algo_pop_heap algo_pop_heap_if.................................................................................................57
5.3.17.algo_make_heap algo_make_heap_if............................................................................................57
5.3.18.algo_sort_heap algo_sort_heap_if.................................................................................................57
5.3.19.algo_is_heap algo_is_heap_if........................................................................................................58
5.3.20.algo_min algo_min_if....................................................................................................................58
5.3.21.algo_max algo_max_if...................................................................................................................58
5.3.22.algo_min_element algo_min_element_if.......................................................................................59
5.3.23.algo_max_element algo_max_element_if.....................................................................................59
5.3.24.algo_lexicographical_compare algo_lexicographical_compare_if...............................................59
5.3.25.algo_lexicographical_compare_3wap algo_lexicographical_compare_3way_if..........................60
5.3.26.algo_next_permutation algo_next_permutation_if........................................................................60
5.3.27.algo_prev_permutation algo_prev_permutation_if.......................................................................60
5.4.算术算法....................................................................................................................................................61
5.4.1.algo_iota..............................................................................................................................................61
5.4.2.algo_accumulate algo_accumulate_if..............................................................................................61
5.4.3.algo_inner_product algo_inner_product_if.....................................................................................61
5.4.4.algo_partial_sum algo_partial_sum_if.............................................................................................62
5.4.5.algo_adjacent_difference algo_adjacent_difference_if...................................................................62
5.4.6.algo_power algo_power_if..............................................................................................................62
6.工具类型............................................................................................................................................................64
6.1.bool_t..........................................................................................................................................................64
6.2.pair_t...........................................................................................................................................................64
7.函数类型............................................................................................................................................................66
7.1.算术运算函数............................................................................................................................................66
7.1.1.plus......................................................................................................................................................66
7.1.2.minus...................................................................................................................................................66
7.1.3.multiplies.............................................................................................................................................67
7.1.4.divides.................................................................................................................................................67
7.1.5.modulus...............................................................................................................................................67
7.1.6.negate..................................................................................................................................................68
7.2.关系运算函数............................................................................................................................................68
7.2.1.equal_to...............................................................................................................................................68
7.2.2.not_equal_to........................................................................................................................................68
7.2.3.less.......................................................................................................................................................69
7.2.4.less_equal............................................................................................................................................69
7.2.5.great.....................................................................................................................................................70
7.2.6.great_equal..........................................................................................................................................70
7.3.逻辑运算函数............................................................................................................................................70
7.3.1.logical_and..........................................................................................................................................70
7.3.2.logical_or............................................................................................................................................71
7.3.3.logical_not...........................................................................................................................................71
7.4.其他函数....................................................................................................................................................71
7.4.1.random_number..................................................................................................................................71
7.4.2.default.................................................................................................................................................71
1. libcstl 简介
libcstl 模仿 SGI STL 写成的,为 C 语言编程提供了通用的数据结构和算法的库。libcstl 提供的数据结构类型是
通用的,它们可以用来保存各种类型的数据。同时 libcstl 还提供了大量的算法用于管理数据结构中的数据。
1.1. 容器和算法
libcstl 容器是结构体类型,可以保存任何类型的数据。如 create_vector(int);就创建了一个用于保存
int 类型的 vector_t 容器类型:
vector_t t_v = create_vector(int);
libcstl 同样包含一系列算法,算法用来管理容器中的数据。你可以使用逆序算法使容器中的数据逆序:
algo_reverse(vector_begin(&t_v), vector_end(&t_v));
同样这个算法还可以用在其他容器上:
deque_t t_dq = create_deque(double);
…
algo_reverse(deque_begin(&t_dq), deque_end(&t_dq));
1.2. 迭代器
迭代器是容器和算法的桥梁,算法通过迭代器组成的数据空间就可以管理任何容器,每一容器都提供了与迭
代器相关的操作函数,如 vector_begin()和 vector_end()。libcstl 还提供了很多与迭代器相关的操作函数,如
通过迭代器获得数据,修改数据,获得数据的指针,向前或向后移动迭代器等。
1.3. libcstl 其他组成部分
libcstl 还提供了工具类型:pair_t, bool_t。这些类型是供其他容器类型使用的。此外 libcstl 提供了函数,用来扩
展算法的执行规则。
剩余70页未读,继续阅读
油条大侠
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1