Item 22
-change an element in a set or multiset, you must be sure not to change a key part.【76~78】
-some implementations keeps the elements of set/multiset from being modified by having operator* for a set<T>::iterator return a const T&.【78】
-use "cast to a reference" to change a non-key portion of an element in a set or a multiset.【79】
-"cast to a object" don't work because the result of the cast is a temporary anonymous object【79】
-★by casting to a reference,we avoid creating a new object. Instead, the result of the cast is a reference to anexisting object【80】
-the first component of the pair whitch is the element of the map is defined to be const【80】
-how to change an element in a set, multiset, map, or multimap without cast【80】
Item 30
-the iterator return by back_inserter causes push_back to be called【p107】
-front_inserter causes "reverse", iterate over values in reverse order(values.rbegin(). values.rend(),) to keep the output to be in the same order as corresponding objects.【p108】
-inserters make each insertion into the destination range is done one object at a time.it's expansive for contiguous-memory containers.vector or string can minimize the expense by "reserve()".【p108】
-clear the destination range and use an inserter to overwrite.【p110】
Item 31
-partial_sort:partially put things in order【p111】
-nth_element:identify the top n elements or the element at a particular position【p111】
-partial_sort and nth_element are not stable sorts【p112】
-stable_sort【p112】
-patition/stable_partition:identify all the elements with a quality rating range【p114】
-sort, stable_sort, partial_sort, and nth_element require random access iterators.【p114】
-list offers its sort member funcion(a stable sort).【p114】
-partition and stable_partition require only bidirectional iterators.【p115】
-summarize【p115】
Item 32
-list's member function remove merges remove and erase.【119】
-don't eleminate elements! remove_if and unique are the same【119】
-list::unique really remove things【119】
Item 33
-replace the container of pointers with a container of smart pointers,us the erase-remove idiom directly.【122】
-shared_ptr template in the Boost library.【123】
Item 34
-not all algorithms are applicable to all ranges:
remove requires forward iterators and the ability to make assignments.it can't be applied to input iterators, nor to maps or multimaps, nor to some implementations of set and multiset【p123】
many of the sorting algorithms demand random access iterators, so it's not possible to invoke these algorithms on the elements of a list.【p123】
-