Effective STL : 50 specific ways to improve your use of the standard template library = STL高效编...
副标题:无
作 者:Scott Meyers著.
分类号:
ISBN:9787111196242
微信扫一扫,移动浏览光盘
简介
C++的标准模板库(STL)是革命性的,但是要想学会用好STL却充满了挑战性。中国台湾技术作家侯捷先生曾经把STL的学习过程比喻为三个境界:
第一境界:熟用STL。
第二境界:了解泛型技术的内涵与STL的学理乃至实作。
第三境界:扩充STL。
本书无疑是你达到第二境界的最佳读本。在本书中,C++技术权威Scott Meyers揭示了专家总结的一些关键规则,包括他们总是采用的做法以及总是避免的做法。这些规则可以发挥STL的最大效用。
有些书只是描述STL中有些什么内容,而本书则讲述如何使用STL。本书共有50条指导原则,在讲述每一条指导原则时,Scott Meyers都提供了透彻的分析和深刻的实例,所以读者不仅可以学到要做什么,而且还能够知道什么时候该这样做,以及为什么要这样做。
如同Meyers的其他著作一样,本书充满了从实践中总结出来的智慧。清晰、简明、透彻的风格使本书成为每一位STL程序员的案头必备。
本书特色
●关于选择容器的建议,涉及的容器有:标准STL容器(例如vector和list)、非标准的STL容器(例如hash_set和hash_map),以及非STL容器(例如bitset)。
●一些提高效率的技术,通过它们可以最大程度地提高STL(以及使用STL的程序)的效率。
●深入到迭代器、函数对象和分配子(allocator)的行为,也包括程序员总是应该避免的做法。
●对于那些同名的算法和成员函数,如find,根据它们行为方式上的微妙差异,本书给出了一些指导原则,以保证它们能被正确地使用。
●讨论了潜在的移植性问题,包括避免这些移植性问题的各种简单途径。
目录
table of contents
preface xi
acknowledgments xv
introduction
chapter 1: containers
item 1: choose your containers with care.
item 2: beware the illusion of container-independent code.
item 3: make copying cheap and correct for objects in containers.
item 4: call empty instead of checking size() against zero.
item 5: prefer range member functions to their single-element counterparts.
item 6: be alert for c++’s most vexing parse.
item 7: when using containers of newed pointers, remember to delete the pointers before the container is destroyed.
item 8: never create containers of auto_ptrs.
item 9: choose carefully among erasing options.
item 10: be aware of allocator conventions and restrictions.
item 11: understand the legitimate uses of custom allocators.
item 12: have realistic expectations about the thread safety of stl containers.
chapter 2: vector and string
item 13: prefer vector and string to dynamically allocated arrays.
item 14: use reserve to avoid unnecessary reallocations.
.item 15: be aware of variations in string implementations.
item 16: know how to pass vector and string data to legacy apis.
item 17: use “the swap trick” to trim excess capacity.
item 18: avoid using vector[bool].
chapter 3: associative containers
item 19: understand the difference between equality and equivalence.
item 20: specify comparison types for associative containers of pointers.
item 21: always have comparison functions return false for equal values.
item 22: avoid in-place key modification in set and multiset.
item 23: consider replacing associative containers with sorted vectors.
item 24: choose carefully between map::operator[] and map::insert when efficiency is important.
item 25: familiarize yourself with the nonstandard hashed containers.
chapter 4: iterators
item 26: prefer iterator to const_iterator, reverse_iterator, and const_reverse_iterator.
item 27: use distance and advance to convert const_iterators to iterators.
item 28: understand how to use a reverse_iterator’s base iterator.
item 29: consider istreambuf_iterators for character by character input.
chapter 5: algorithms
item 30: make sure destination ranges are big enough.
item 31: know your sorting options.
item 32: follow remove-like algorithms by erase if you really want to remove something.
item 33: be wary of remove-like algorithms on containers of pointers.
item 34: note which algorithms expect sorted ranges.
item 35: implement simple case-insensitive string comparisons via mismatch or lexicographical_compare.
item 36: understand the proper implementation of copy_if.
item 37: use accumulate or for_each to summarize ranges.
chapter 6: functors, functor classes, functions, etc.
item 38: design functor classes for pass-by-value.
item 39: make predicates pure functions.
item 40: make functor classes adaptable.
item 41: understand the reasons for ptr_fun, mem_fun, and mem_fun_ref.
item 42: make sure less[t] means operator[.
chapter 7: programming with the stl
item 43: prefer algorithm calls to hand-written loops.
item 44: prefer member functions to algorithms with the same names.
item 45: distinguish among count, find, binary_search, lower_bound, upper_bound, and equal_range.
item 46: consider function objects instead of functions as algorithm parameters.
item 47: avoid producing write-only code.
item 48: always #include the proper headers.
item 49: learn to decipher stl-related compiler diagnostics.
item 50: familiarize yourself with stl-related web sites.
bibliography
appendix a: locales and case-insensitive string comparisons
appendix b: remarks on microsoft’s stl platforms
index
preface xi
acknowledgments xv
introduction
chapter 1: containers
item 1: choose your containers with care.
item 2: beware the illusion of container-independent code.
item 3: make copying cheap and correct for objects in containers.
item 4: call empty instead of checking size() against zero.
item 5: prefer range member functions to their single-element counterparts.
item 6: be alert for c++’s most vexing parse.
item 7: when using containers of newed pointers, remember to delete the pointers before the container is destroyed.
item 8: never create containers of auto_ptrs.
item 9: choose carefully among erasing options.
item 10: be aware of allocator conventions and restrictions.
item 11: understand the legitimate uses of custom allocators.
item 12: have realistic expectations about the thread safety of stl containers.
chapter 2: vector and string
item 13: prefer vector and string to dynamically allocated arrays.
item 14: use reserve to avoid unnecessary reallocations.
.item 15: be aware of variations in string implementations.
item 16: know how to pass vector and string data to legacy apis.
item 17: use “the swap trick” to trim excess capacity.
item 18: avoid using vector[bool].
chapter 3: associative containers
item 19: understand the difference between equality and equivalence.
item 20: specify comparison types for associative containers of pointers.
item 21: always have comparison functions return false for equal values.
item 22: avoid in-place key modification in set and multiset.
item 23: consider replacing associative containers with sorted vectors.
item 24: choose carefully between map::operator[] and map::insert when efficiency is important.
item 25: familiarize yourself with the nonstandard hashed containers.
chapter 4: iterators
item 26: prefer iterator to const_iterator, reverse_iterator, and const_reverse_iterator.
item 27: use distance and advance to convert const_iterators to iterators.
item 28: understand how to use a reverse_iterator’s base iterator.
item 29: consider istreambuf_iterators for character by character input.
chapter 5: algorithms
item 30: make sure destination ranges are big enough.
item 31: know your sorting options.
item 32: follow remove-like algorithms by erase if you really want to remove something.
item 33: be wary of remove-like algorithms on containers of pointers.
item 34: note which algorithms expect sorted ranges.
item 35: implement simple case-insensitive string comparisons via mismatch or lexicographical_compare.
item 36: understand the proper implementation of copy_if.
item 37: use accumulate or for_each to summarize ranges.
chapter 6: functors, functor classes, functions, etc.
item 38: design functor classes for pass-by-value.
item 39: make predicates pure functions.
item 40: make functor classes adaptable.
item 41: understand the reasons for ptr_fun, mem_fun, and mem_fun_ref.
item 42: make sure less[t] means operator[.
chapter 7: programming with the stl
item 43: prefer algorithm calls to hand-written loops.
item 44: prefer member functions to algorithms with the same names.
item 45: distinguish among count, find, binary_search, lower_bound, upper_bound, and equal_range.
item 46: consider function objects instead of functions as algorithm parameters.
item 47: avoid producing write-only code.
item 48: always #include the proper headers.
item 49: learn to decipher stl-related compiler diagnostics.
item 50: familiarize yourself with stl-related web sites.
bibliography
appendix a: locales and case-insensitive string comparisons
appendix b: remarks on microsoft’s stl platforms
index
Effective STL : 50 specific ways to improve your use of the standard template library = STL高效编...
- 名称
- 类型
- 大小
光盘服务联系方式: 020-38250260 客服QQ:4006604884
云图客服:
用户发送的提问,这种方式就需要有位在线客服来回答用户的问题,这种 就属于对话式的,问题是这种提问是否需要用户登录才能提问
Video Player
×
Audio Player
×
pdf Player
×