C++ Standard Template Library Algorithm














































C++ Standard Template Library Algorithm



STL ALGORITHMS

Name: for_each
Purpose: applies function to each object
Arguments: first, last, function

Name: find
Purpose: returns iterator to the first object equal to value
Arguments: first, last, value

Name: find_if
Purpose:  returns iterator to the first object for which predicate is true
Arguments: first, last, predicate

Name: adjacent_find
Purpose:  returns iterator to the first adjacent pair of objects that are equal
Arguments: first, last

Name: adjacent_find
Purpose:  returns iterator to the first adjacent pair of object for which predicate is true
Arguments: first, last, predicate

Name: count
Purpose: adds to n the number of objects equals to value
Arguments: first, last, value, n

Name: count_if
Purpose: adds to n the number of objects satisfying predicate
Arguments: first, last, predicate, n

Name: mismatch
Purpose: returns first non-equal pair of corresponding objects in two range
Arguments: first1, last1, first2

Name: mismatch
Purpose: returns first pair of corresponding object  in two range that don't satisfy predicate
Arguments: first1, last1, first2, predicate

Name: equal
Purpose: returns true if corresponding objects in two range are all equal
Arguments: first1, last1, first2

Name: equal
Purpose: returns true if corresponding objects in two ranges all satisfy predicate
Arguments: first1, last1, first2, predicate

Name: search
Purpose: check whether second range is contained within first.
                return first of match of last1 if no match
Arguments: first1, last1, first2, last2

Name: search
Purpose: check whether second range is contained within first where equality is determined by the predicate
               returns start of match or last1 if no match 
Arguments: first1, last1, first2, last2, predicate

Mutating sequence operation

Name: copy
Purpose: returns copies object from range 1 to range 2
Arguments: first1, last1, first2

Name: copy_backward
Purpose: returns copies object from range 1 to range 2, inserting backward from last2 to first2 
Arguments: first1, last1, first2

Name: swap
Purpose: interchange two objects
Arguments: a, b

Name: iter_swap
Purpose: interchange two objects pointed by two iterators. 
Arguments: iter1, iter2

Name: swap_ranges
Purpose:  interchange corresponding elements in two ranges
Arguments: first1, last1, first2

Name: transform
Purpose: Transform objects in range 1 into new bject in rnge 2 by aplying operator 
Arguments: first1, last1, first2, operator

Name: transform
Purpose: returns copies object from range 1 to range 2 Combines object of range 1 and range 2 into new objects in range 3 by applying  operator
Arguments: first1, last1, first2, first3, operator

Name: replace
Purpose: replace all objects equal to old with objects equal to new
Arguments: first, last, old, new

Name: replace_if
Purpose: replace all objects that satisfy predicate with objects equal to new
Arguments: first, last, predicate, new

Name: replace_copy
Purpose: copies from range 1 to range 2, replacing all objects equal to old with objects equal to new
Arguments: first1, last1, first2, old, new

Name: replace_copy_if
Purpose: copies from range 1 to range 2, replacing all objects that satisfy predicate with objects equal to new
Arguments: first1, last1, first2, predicate , new

Name: fill
Purpose: assign value to all objects in range
Arguments: first, last, value

Name: fill_n
Purpose: assign value to all objects from first to first+n
Arguments: first, last, value

Name: generate
Purpose: fills range with values generated by successive calls to function gen
Arguments: first, last, gen

Name: generate_n
Purpose: fills from first to first+n  with values generated by successive calls to function gen
Arguments: first, last, gen

Name: remove
Purpose: remove from range any object equals to value
Arguments: first, last, value

Name: remove_if
Purpose: remove from range any object that satisfy predicate
Arguments: first, last, predicate


Name: remove_copy
Purpose:  copies objects, excepting those equal to value from range 1 to range 2. 
Arguments: first1, last1, first2, value

Name: remove_copy_if
Purpose:  copies objects, excepting those satisfying predicate from range 1 to range 2.
Arguments: first1, last1,first2,predicate





Comments