- 1、本文档共53页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
面向对象的程序设计方法第六讲STL剖析与高效编程
面向对象的程序设计方法第六讲 STL剖析与高效编程 华中科技大学 吴义忠 内容提要 1、抽象容器剖析(string, vector, list, deque, hash_map) 2、泛型算法剖析:以sort()为例,类型参数化,容器参数化,操作参数化,函数对象,适配器 3、模板与泛型算法编程 4、STL高效编程规则 5、Boost库简介 1.1 std::string typedef basic_stringchar string; template class CharType, class Traits=char_traitsCharType, class Allocator=allocatorCharType class basic_string //参数 CharType The data type of a single character to be stored in the string. The Standard C++ Library provides two specializations of this template class, with the type definitions string, for elements of type char, and wstring, for elements of type wchar_t. Traits Various important properties of the CharType elements in a basic_string specialization are described by the class Traits. Allocator The type that represents the stored allocator object that encapsulates details about the strings allocation and deallocation of memory. The default value is allocatorType. 缺省字符属性char_traits template class CharType struct char_traits; char_traitschar可以帮助转换 char_traitschar::char_type ch1 = x; char_traitschar::char_type ch2 = y; // Converting from char_type to int_type char_traitschar::int_type int1, int2 , int3; int1 =char_traitschar:: to_int_type ( ch1 ); int2 =char_traitschar:: to_int_type ( ch2 ); cout The char_types and corresponding int_types are: \n ch1 = ch1 corresponding to int1 = int1 . \n ch2 = ch2 corresponding to int1 = int2 . The char_types and corresponding int_types are: ch1 = x corresponding to int1 = 120. ch2 = y corresponding to int1 = 121 basic_string在实现过程(append, insert…)中调用char_traitschar的静态成员 static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2, size_t _Count) { // copy [_First1, _First1 + _Count) to [_First2, ...) return (::wmemcpy(_First1, _First2, _Count)); } static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2, size_t _Count) { // copy [_First1, _First1 + _Count) to [_First2, ...) retur
您可能关注的文档
最近下载
- 人乳头瘤病毒感染护理.pptx VIP
- 压疮品管圈成果汇报PPT幻灯片.ppt VIP
- 车险承保方案.pdf VIP
- 中华民族共同体概论教案合集(第一讲-第十六讲)附《中华民族共同体概论》课程大纲.doc VIP
- “中华民族共同体概论”课程教学与建设关键问题探讨.docx VIP
- 诸侯纷争与变法运动【课件】.pptx VIP
- 中国高血压防治指南(2024年修订版)_中国高血压防治指南修订委员会__.pdf VIP
- “扬子石化杯”2024年第38届中国化学奥林匹克(江苏赛区)初赛化学.pdf VIP
- 民事诉讼法中案外第三人对执行的异议之诉.pdf VIP
- “扬子石化杯”2024年第38届中国化学奥林匹克(江苏赛区)初赛化学试卷含答案.pdf VIP
文档评论(0)