Effective STL item 43, Prefer algorithm calls to hand-written loops.
But if you need a loop that dees something fairly simpler, but would
require a confusing tangle of binders and adapters, just use loop.
Know you sorting options: It makes no sense to sort elements in standard
associative containers, because such containers use their comparison
functions to remain sorted all the time.
For other sequence container, sorting options is below: (1-3) need random
iterator. 4 only need bidirection iterator.(list)
full sort on vector, string, deque, or array. use sort or stable_sort
put only the top n elements in order, partial_sort
Identify the elements at positon n , you need nth_element
spearate the elements of a standard sequence container, do satisfy
some criterion, you use partition or stable_partition.
for list, you should use list.sort() in place of common sort.
For a algorithms, you need to know three points: 1) what’sfunction for 2) what iterator it accept, 3) what functor it willaccept. So please see below summary.