|
template<class InputArray , class T > |
constexpr bool | jau::contains (InputArray &array, const T &value) |
| Return true if value is contained in array . More...
|
|
template<class InputIt , class T > |
constexpr InputIt | jau::find (InputIt first, InputIt last, const T &value) |
| Like std::find() of 'algorithm'. More...
|
|
template<class T > |
const T::value_type * | jau::find_const (T &data, typename T::value_type const &elem, std::enable_if_t< !is_cow_type< T >::value, bool >=true) noexcept |
|
template<class T > |
const T::value_type * | jau::find_const (T &data, typename T::value_type const &elem, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept |
|
template<class InputIt , class UnaryPredicate > |
constexpr InputIt | jau::find_if (InputIt first, InputIt last, UnaryPredicate p) |
| Like std::find_if() of 'algorithm'. More...
|
|
template<class InputIt , class UnaryPredicate > |
constexpr InputIt | jau::find_if_not (InputIt first, InputIt last, UnaryPredicate q) |
| Like std::find_if_not() of 'algorithm'. More...
|
|
template<class InputIt , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each (InputIt first, InputIt last, UnaryFunction f) |
| Like std::for_each() of 'algorithm'. More...
|
|
template<class T , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_const (T &data, UnaryFunction f, std::enable_if_t< !is_cow_type< T >::value, bool >=true) noexcept |
|
template<class T , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_const (T &data, UnaryFunction f, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept |
|
template<class InputIt , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_fidelity (InputIt first, InputIt last, UnaryFunction f) |
| Like jau::for_each(), see above. More...
|
|
template<class T , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_fidelity (T &data, UnaryFunction f, std::enable_if_t< !is_cow_type< T >::value, bool >=true) noexcept |
| See jau::for_each_fidelity() More...
|
|
template<class T , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_fidelity (T &data, UnaryFunction f, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept |
| See jau::for_each_fidelity() More...
|
|
template<class InputArray , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_idx (InputArray &array, UnaryFunction f) |
| Custom for_each template, using indices instead of iterators, allowing container to be modified within lambda 'callback'. More...
|
|
template<class Mutex , class InputArray , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_idx_mtx (Mutex &mtx, InputArray &array, UnaryFunction f) |
| Custom for_each template, same as jau::for_each but using indices instead of iterators and a mutex. More...
|
|
template<class Mutex , class InputIt , class UnaryFunction > |
constexpr UnaryFunction | jau::for_each_mtx (Mutex &mtx, InputIt first, InputIt last, UnaryFunction f) |
| Custom for_each template, same as jau::for_each but using a mutex. More...
|
|
template<class ForwardIt , class UnaryPredicate > |
ForwardIt | jau::remove_if (ForwardIt first, ForwardIt last, UnaryPredicate p) |
| Identical to C++20 std::remove_if() of algorithm More...
|
|
Basic algorithms.
template<class InputIt , class UnaryFunction >
constexpr UnaryFunction jau::for_each_fidelity |
( |
InputIt |
first, |
|
|
InputIt |
last, |
|
|
UnaryFunction |
f |
|
) |
| |
|
constexpr |
Like jau::for_each(), see above.
Additionally this template function removes the const
qualifier of the UnaryFunction
sole argument.
The latter is retrieved by dereferencing the iterator, which might expose the const
qualifier if the iterator is a const_iterator
.
Implementation casts argument in the following fashion const_cast<value_type*>(&arg)
, allowing to use const_iterator
and subsequent non-const features of the argument, see below.
Such situations may occur when preferring to use the const_iterator
over non-const.
jau::cow_darray is such a scenario, where one might not mutate the elements of the container itself but needs to invoke non-const functions in good faith.
Here we can avoid costly side-effects of copying the CoW storage for later replacement.
See jau::cow_ro_iterator and jau::cow_rw_iterator in conjunction with jau::cow_darray.
Requirements for the given IteratorIt type are to have typename InputIt::value_type
available.
- Template Parameters
-
InputIt | the iterator type, which might be a 'const_iterator' for non const types. |
UnaryFunction | |
- Parameters
-
first | range start of elements to apply the function |
last | range end of elements to apply the function |
f | the function object, like void fun(const Type &a) |
- Returns
- the function
- See also
- jau::cow_darray
-
jau::cow_ro_iterator
-
jau::cow_rw_iterator
Definition at line 275 of file basic_algos.hpp.
template<class Mutex , class InputArray , class UnaryFunction >
constexpr UnaryFunction jau::for_each_idx_mtx |
( |
Mutex & |
mtx, |
|
|
InputArray & |
array, |
|
|
UnaryFunction |
f |
|
) |
| |
|
constexpr |
Custom for_each template, same as jau::for_each but using indices instead of iterators and a mutex.
Method performs UnaryFunction on all elements [0..n-1], where n is being retrieved once before the loop!
This method also utilizes a given mutex to ensure thread-safety, by operating within an RAII-style std::lock_guard block.
Definition at line 340 of file basic_algos.hpp.