Ray's playground

 

Library Organization and Containers(Chapter 16 of The C++ Programming Language)

[1] Use standard library facilities to maintain portability; 
[2] Don’t try to redefine standard library facilities; 
[3] Don’t believe that the standard library is best for everything.
[4] When building a new facility, consider whether it can be presented within the framework offered by the standard library; 
[5] Remember that standard library facilities are defined in namespace std; 
[6] Declare standard library facilities by including its header, not by explicit declaration; 
[7] Take advantage of late abstraction; 
[8] Avoid fat interfaces; 
[9] Prefer algorithms with reverse iterators over explicit loops dealing with reverse order;
[10] Use base() to extract an iterator from a reverse_iterator;
[11] Pass containers by reference;
[12] Use iterator types, such as list<char>::iterator, rather than pointers to refer to elements of a container;
[13] Use const iterators where you don’t need to modify the elements of a container;
[14] Use at(), directly or indirectly, if you want range checking;
[15] Use push_back() or resize() on a container rather than realloc() on an array;
[16] Don’t use iterators into a resized vector;
[17] Use reserve() to avoid invalidating iterators;
[18] When necessary, use reserve() to make performance predictable;

posted on 2010-08-11 21:00  Ray Z  阅读(211)  评论(0编辑  收藏  举报

导航