AlgorithmΒΆ
Functions that, in the same spirit of the STL, complement the <algorithm>
header.
-
template <typename T, typename Compare = stdc::less<T>, typename... Rest> constexpr bool is_sorted(T first, T second, Rest... rest)
Checks if the elements
[first,second,rest...]
are sorted in non-descending order according to theCompare
criteria, which defaults tostdc::less<T>
-
template <typename Container> typename Container::iterator erase_remove(Container& container, typename Container::value_type const& value)
Removes all elements from
container
that are equal tovalue
.Post: The size()
of the container is reduced by the number of elements that were removedReturns: Past-the-end iterator after the elements are removed
-
template <typename Container, typename UnaryPredicate> typename Container::iterator erase_remove_if(Container& container, UnaryPredicate pred)
Removes all elements from
container
for which predicatepred
returnstrue
.Parameters: - container – The container from which elements will be removed
- pred – The predicate to be applied to all elements in the container
Post: The
size()
of the container is reduced by the number of elements that were removedReturns: Past-the-end iterator after the elements are removed