Op werkdagen voor 23:00 besteld, morgen in huis Gratis verzending vanaf €20

Effective STL

50 Specific Ways to Improve Your Use of the Standard Template Library

Specificaties
E-book, blz. | Engels
Pearson Education | e druk, 2001
ISBN13: 9780132702072
Rubricering
Juridisch :
Pearson Education e druk, 2001 9780132702072
Verwachte levertijd ongeveer 9 werkdagen

Samenvatting

“This is Effective C++ volume three – it’s really that good.”
– Herb Sutter, independent consultant and secretary of the ISO/ANSI C++ standards committee “There are very few books which all C++ programmers must have. Add Effective STL to that list.”
– Thomas Becker, Senior Software Engineer, Zephyr Associates, Inc., and columnist, C/C++ Users Journal

C++’s Standard Template Library is revolutionary, but learning to use it well has always been a challenge. Until now. In this book, best-selling author Scott Meyers (Effective C++, and More Effective C++) reveals the critical rules of thumb employed by the experts – the things they almost always do or almost always avoid doing – to get the most out of the library.

Other books describe what’s in the STL. Effective STL shows you how to use it. Each of the book’s 50 guidelines is backed by Meyers’ legendary analysis and incisive examples, so you’ll learn not only what to do, but also when to do it – and why.

Highlights of Effective STL include: Advice on choosing among standard STL containers (like vector and list), nonstandard STL containers (like hash_set and hash_map), and non-STL containers (like bitset). Techniques to maximize the efficiency of the STL and the programs that use it. Insights into the behavior of iterators, function objects, and allocators, including things you should not do. Guidance for the proper use of algorithms and member functions whose names are the same (e.g., find), but whose actions differ in subtle (but important) ways. Discussions of potential portability problems, including straightforward ways to avoid them.

Like Meyers’ previous books, Effective STL is filled with proven wisdom that comes only from experience. Its clear, concise, penetrating style makes it an essential resource for every STL programmer.

Specificaties

ISBN13:9780132702072
Taal:Engels
Bindwijze:e-book

Inhoudsopgave

<h3>Preface&nbsp;&nbsp;xi</h3> <h3>Acknowledgments&nbsp;&nbsp;xv</h3> <h3>Introduction&nbsp;&nbsp;1</h3> <h3>Chapter 1: Containers&nbsp;&nbsp;11</h3> <p>Item 1: Choose your containers with care.&nbsp;&nbsp;11</p> <p>Item 2: Beware the illusion of container-independent code.&nbsp;&nbsp;15</p> <p>Item 3: Make copying cheap and correct for objects in containers.&nbsp;&nbsp;20</p> <p>Item 4: Call <font size="2" face="Courier">empty</font> instead of checking <font size="2" face="Courier">size()</font> against zero.&nbsp;&nbsp;23</p> <p>Item 5: Prefer range member functions to their single-element counterparts.&nbsp;&nbsp;24</p> <p>Item 6: Be alert for C++’s most vexing parse.&nbsp;&nbsp;33</p> <p>Item 7: When using containers of <font size="2" face="Courier">newed</font> pointers, remember to <font size="2" face="Courier">delete</font> the pointers before the container is destroyed.&nbsp;&nbsp;36</p> <p>Item 8: Never create containers of <font size="2" face="Courier">auto_ptr</font>s.&nbsp;&nbsp;40</p> <p>Item 9: Choose carefully among erasing options.&nbsp;&nbsp;43</p> <p>Item 10: Be aware of allocator conventions and restrictions.&nbsp;&nbsp;48</p> <p>Item 11: Understand the legitimate uses of custom allocators.&nbsp;&nbsp;54</p> <p>Item 12: Have realistic expectations about the thread safety of STL containers.&nbsp;&nbsp;58</p> <h3>Chapter 2: <font face="Courier">vector</font> and <font face="Courier">string</font>&nbsp;&nbsp;63</h3> <p>Item 13: Prefer <font size="2" face="Courier">vector</font> and <font size="2" face="Courier">string</font> to dynamically allocated arrays.&nbsp;&nbsp;63</p> <p>Item 14: Use <font size="2" face="Courier">reserve</font> to avoid unnecessary reallocations.&nbsp;&nbsp;66</p> <p>Item 15: Be aware of variations in <font size="2" face="Courier">string</font> implementations.&nbsp;&nbsp;68</p> <p>Item 16: Know how to pass <font size="2" face="Courier">vector</font> and <font size="2" face="Courier">string</font> data to legacy APIs.&nbsp;&nbsp;74</p> <p>Item 17: Use “the swap trick” to trim excess capacity.&nbsp;&nbsp;77</p> <p>Item 18: Avoid using <font size="2" face="Courier">vector&lt;bool&gt;</font>.&nbsp;&nbsp;79</p> <h3>Chapter 3: Associative Containers&nbsp;&nbsp;83</h3> <p>Item 19: Understand the difference between equality and equivalence.&nbsp;&nbsp;83</p> <p>Item 20: Specify comparison types for associative containers of pointers. 88</p> <p>Item 21: Always have comparison functions return <font size="2" face="Courier">false</font> for equal values.&nbsp;&nbsp;92</p> <p>Item 22: Avoid in-place key modification in <font size="2" face="Courier">set</font> and <font size="2" face="Courier">multiset</font>.&nbsp;&nbsp;95</p> <p>Item 23: Consider replacing associative containers with sorted <font size="2" face="Courier">vector</font>s.&nbsp;&nbsp;100</p> <p>Item 24: Choose carefully between <font size="2" face="Courier">map::operator[]</font> and <font size="2" face="Courier">map::insert</font> when efficiency is important. &nbsp;&nbsp;106</p> <p>Item 25: Familiarize yourself with the nonstandard hashed containers.&nbsp;&nbsp;111</p> <h3>Chapter 4: Iterators&nbsp;&nbsp;116</h3> <p>Item 26: Prefer <font size="2" face="Courier">iterator</font> to <font size="2" face="Courier">const_iterator</font>, <font size="2" face="Courier">reverse_iterator</font>, and <font size="2" face="Courier">const_reverse_iterator</font>.&nbsp;&nbsp;116</p> <p>Item 27: Use <font size="2" face="Courier">distance</font> and <font size="2" face="Courier">advance</font> to convert <font size="2" face="Courier">const_iterator</font>s to <font size="2" face="Courier">iterator</font>s. &nbsp;&nbsp;120</p> <p>Item 28: Understand how to use a <font size="2" face="Courier">reverse_iterator</font>’s base <font size="2" face="Courier">iterator</font>.&nbsp;&nbsp;123</p> <p>Item 29: Consider <font size="2" face="Courier">istreambuf_iterator</font>s for character by character input.&nbsp;&nbsp;126</p> <h3>Chapter 5: Algorithms&nbsp;&nbsp;128</h3> <p>Item 30: Make sure destination ranges are big enough.&nbsp;&nbsp;129</p> <p>Item 31: Know your sorting options.&nbsp;&nbsp;133</p> <p>Item 32: Follow <font size="2" face="Courier">remove</font>-like algorithms by <font size="2" face="Courier">erase</font> if you really want to remove something.&nbsp;&nbsp;139</p> <p>Item 33: Be wary of <font size="2" face="Courier">remove</font>-like algorithms on containers of pointers.&nbsp;&nbsp;143</p> <p>Item 34: Note which algorithms expect sorted ranges.&nbsp;&nbsp;146</p> <p>Item 35: Implement simple case-insensitive string comparisons via <font size="2" face="Courier">mismatch</font> or <font size="2" face="Courier">lexicographical_compare</font>.&nbsp;&nbsp;150</p> <p>Item 36: Understand the proper implementation of <font size="2" face="Courier">copy_if</font>.&nbsp;&nbsp;154</p> <p>Item 37: Use <font size="2" face="Courier">accumulate</font> or <font size="2" face="Courier">for_each</font> to summarize ranges.&nbsp;&nbsp;156</p> <h3>Chapter 6: Functors, Functor Classes, Functions, etc.&nbsp;&nbsp;162</h3> <p>Item 38: Design functor classes for pass-by-value.&nbsp;&nbsp;162</p> <p>Item 39: Make predicates pure functions.&nbsp;&nbsp;166</p> <p>Item 40: Make functor classes adaptable.&nbsp;&nbsp;169</p> <p>Item 41: Understand the reasons for <font size="2" face="Courier">ptr_fun</font>, <font size="2" face="Courier">mem_fun</font>, and <font size="2" face="Courier">mem_fun_ref</font>.&nbsp;&nbsp;173</p> <p>Item 42: Make sure <font size="2" face="Courier">less&lt;T&gt;</font> means <font size="2" face="Courier">operator&lt;</font>.&nbsp;&nbsp;177</p> <h3>Chapter 7: Programming with the STL&nbsp;&nbsp;181</h3> <p>Item 43: Prefer algorithm calls to hand-written loops.&nbsp;&nbsp;181</p> <p>Item 44: Prefer member functions to algorithms with the same names.&nbsp;&nbsp;190</p> <p>Item 45: Distinguish among <font size="2" face="Courier">count</font>, <font size="2" face="Courier">find</font>, <font size="2" face="Courier">binary_search</font>, <font size="2" face="Courier">lower_bound</font>, <font size="2" face="Courier">upper_bound</font>, and <font size="2" face="Courier">equal_range</font>.&nbsp;&nbsp;192</p> <p>Item 46: Consider function objects instead of functions as algorithm parameters.&nbsp;&nbsp;201</p> <p>Item 47: Avoid producing write-only code.&nbsp;&nbsp;206</p> <p>Item 48: Always <font size="2" face="Courier">#include</font> the proper headers.&nbsp;&nbsp;209</p> <p>Item 49: Learn to decipher STL-related compiler diagnostics.&nbsp;&nbsp;210</p> <p>Item 50: Familiarize yourself with STL-related web sites.&nbsp;&nbsp;217</p> <h3>Bibliography&nbsp;&nbsp;225</h3> <h3>Appendix A: Locales and Case-Insensitive String Comparisons&nbsp;&nbsp;229</h3> <h3>Appendix B: Remarks on Microsoft’s STL Platforms&nbsp;&nbsp;239</h3> <h3>Index&nbsp;&nbsp;245</h3>

Net verschenen

Rubrieken

Populaire producten

    Personen

      Trefwoorden

        Effective STL