1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
hi(remove) hi(remove_copy) hi(remove_copy_if) hi(remove_if)
itemization(
it() Header file: tt(<algorithm>)
it() Function prototype:
itemization(
itt(ForwardIterator remove([ExecPol,] ForwardIterator first,
ForwardIterator last, Type const &value);)
itt(OutputIterator remove_copy([ExecPol,] InputIterator first,
InputIterator last, OutputIterator dest, Type const &value);)
itt(OutputIterator remove_copy_if([ExecPol,]
InputIterator first, InputIterator last,
OutputIterator dest,
UnaryPredicate pred);)
itt(ForwardIterator remove_if([ExecPol,] ForwardIterator first,
ForwardIterator last, UnaryPredicate pred);)
)
it() Description:
itemization(
it() The first prototype: elements in the range pointed to by
rangett(first, last) are reordered such that all values unequal to tt(value)
are placed at the beginning of the range. The returned forward iterator points
to the first element that can be removed after reordering. The range
rangett(returnvalue, last) is called the emi(leftover) of the algorithm. Note
that the leftover may contain elements different from tt(value), but these
elements can be removed safely, as such elements are also present in the range
rangett(first, returnvalue). The function uses tt(operator==) of the data type
to which the iterators point to determine which elements to remove.
it() The second prototype: elements in the range pointed to by
rangett(first, last) not matching tt(value) are copied to the range
rangett(dest, returnvalue), where tt(returnvalue) is the value returned by
the function. The range rangett(first, last) is not modified. The function
uses tt(operator==) of the data type to which the iterators point to determine
which elements not to copy.
it() The third prototype: the elements in the range pointed to by
rangett(first, last) for which the unary predicate tt(pred) returns tt(true)
are not inserted into the tt(result) iterator. All other elements are copied
to the range rangett(dest, returnvalue), where tt(returnvalue) is the value
returned by the function. The range rangett(first, last) is not modified.
it() The fourth prototype: the elements in the range pointed to by
rangett(first, last) are reordered such that all values for which the unary
predicate tt(pred) returns tt(false) are placed at the beginning of the
range, keeping their relative order. The returned forward iterator
points to the first element, after reordering, for which tt(pred) returned
tt(true). The range rangett(returnvalue, last) is called the em(leftover) of
the algorithm. The leftover em(may) contain elements for which the predicate
tt(pred) returns tt(false), but these can safely be removed, as such elements
are also present in the range rangett(first, returnvalue). Such duplication is
the result of the fact that the algorithm em(copies), rather than em(moves)
elements into new locations.
)
Note that the tt(copy)-overloads expect output iterators. If the
kept elements are to be stored in, e.g., a vector tt(kept) then
tt(kept.begin()) could be passed as the function's tt(dest) argument. However,
that requires that tt(size(kept)) is large enough to contain all the kept
elements, which must therefore be known before the function is
called. Alternatively, tt(back_insert_iterator) could be used ensuring that
tt(kept) merely contains the kept elements once the function has
returned. This approach is used in the example program.
it() Example:
verbinclude(-a examples/remove.cc)
)
|