Note:
1. When using the iterator, you prefer to use ++ POS instead of POS ++. The latter will generate a temporary object, which is out of efficiency considerations.
2. Auto_ptr is not needed as much as possible. Higher security means less flexibility.
3. Try to useAlgorithmReplace loops. When necessary, use custom predicates and function objects as much as possible. The overload operator () is critical.
4. Let's look at the six sorting algorithms. Sort, partion, nth_element .....
5. Remember the differences between vector, list, And deque, and select the most appropriate one.
6. Set is automatically sorted.
7. Binary predicates:
Copy (A. Begin (), A. End (), B. Begin ())
Requirement: the length of B is at least equal to a. The copy operation starts from the first element of Table A until the end of the first element of Table.
Input the element to B in sequence.
Likewise
Equal (A. Begin (), A. End (), B. Being ())
The meaning of this algorithm is to compare the elements in Table A with those in table B one by one. If table A is completely traversed, true is returned if it is equal,
This algorithm is actually a substring search algorithm.
8. To avoid errors, STL provides us with some adapters, which can be used directly to automatically allocate the required space.
Generally, STL provides three types of iterator adapter, back_insertor (table) and insertor (table)
9. Stream iterator Adapter. The syntax is maddening.
10 thus, remove () did not change the number of elements in the collection for which it was called.
When you call remove, you must note that when there are many elements, what is the value of the removed element?
11. Distance (iteraotrb, iteraotre );
Returns the distance between two pointers.
12. We prefer to use Member algorithms instead of general algorithms as much as possible, because universality usually results in a loss of efficiency.