STL高效編程

出版時間:2006-8  出版社:機械工業(yè)出版社  作者:邁耶斯  頁數(shù):260  
Tag標簽:無  

內(nèi)容概要

C++的標準模板庫(STL)是革命性的,但是要想學會用好STL卻充滿了挑戰(zhàn)性。中國臺灣技術(shù)作家侯捷先生曾經(jīng)把STL的學習過程比喻為三個境界:    第一境界:熟用STL。     第二境界:了解泛型技術(shù)的內(nèi)涵與STL的學理乃至實作。     第三境界:擴充STL。     本書無疑是你達到第二境界的最佳讀本。在本書中,C++技術(shù)權(quán)威Scott Meyers揭示了專家總結(jié)的一些關(guān)鍵規(guī)則,包括他們總是采用的做法以及總是避免的做法。這些規(guī)則可以發(fā)揮STL的最大效用。     有些書只是描述STL中有些什么內(nèi)容,而本書則講述如何使用STL。本書共有50條指導原則,在講述每一條指導原則時,Scott Meyers都提供了透徹的分析和深刻的實例,所以讀者不僅可以學到要做什么,而且還能夠知道什么時候該這樣做,以及為什么要這樣做。     如同Meyers的其他著作一樣,本書充滿了從實踐中總結(jié)出來的智慧。清晰、簡明、透徹的風格使本書成為每一位STL程序員的案頭必備。     本書特色    ●關(guān)于選擇容器的建議,涉及的容器有:標準STL容器(例如vector和list)、非標準的STL容器(例如hash_set和hash_map),以及非STL容器(例如bitset)。     ●一些提高效率的技術(shù),通過它們可以最大程度地提高STL(以及使用STL的程序)的效率。   ●深入到迭代器、函數(shù)對象和分配子(allocator)的行為,也包括程序員總是應(yīng)該避免的做法。     ●對于那些同名的算法和成員函數(shù),如find,根據(jù)它們行為方式上的微妙差異,本書給出了一些指導原則,以保證它們能被正確地使用。     ●討論了潛在的移植性問題,包括避免這些移植性問題的各種簡單途徑。

作者簡介

Scott Meyers,擁有布朗大學計算機科學博士學位,是世界頂級的C++軟件開發(fā)技術(shù)權(quán)威之一。他的兩本暢銷書《Effective C++》和《More Effective C++》開創(chuàng)了技術(shù)圖書“Effective”式的寫作風格。他曾擔行《C++ Report》雜志的專欄作家,還經(jīng)常為《C/C++ Users Journal》和《Dr.

書籍目錄

PrefaceAcknowledgmentsIntroductonChapter 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.  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 means operator

圖書封面

圖書標簽Tags

評論、評分、閱讀與下載


    STL高效編程 PDF格式下載


用戶評論 (總計6條)

 
 

  •   閱讀中,因為是英文版,所以讀得要慢一點
  •   這本書實用.
  •   不過感覺沒有第一本書名氣大,不過如果經(jīng)常用stl的話,應(yīng)該好好看看
  •   還算不錯的一本書,不過送貨的速度有待加強
  •   內(nèi)容很好,印刷很爛
  •   學C++,還是C++Primer和C++ProgrammingLanguage
 

250萬本中文圖書簡介、評論、評分,PDF格式免費下載。 第一圖書網(wǎng) 手機版

京ICP備13047387號-7