Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
|
Basic algorithms. More...
Classes | |
class | jau::call_on_release< UnaryFunction > |
Call on release allows the user to pass a function to be called at destruction of this instance. More... | |
class | jau::OptDeleter< T > |
Functions | |
template<class InputArray, class T> | |
constexpr bool | jau::contains (InputArray &array, const T &value) noexcept |
Return true if value is contained in array . | |
template<class InputArray, class T> | |
constexpr bool | jau::eraseFirst (InputArray &array, const T &value) |
template<class InputIt, class T> | |
constexpr InputIt | jau::find (InputIt first, InputIt last, const T &value) noexcept |
Like std::find() of 'algorithm'. | |
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) noexcept |
Like std::find_if() of 'algorithm'. | |
template<class InputIt, class UnaryPredicate> | |
constexpr InputIt | jau::find_if_not (InputIt first, InputIt last, UnaryPredicate q) noexcept |
Like std::find_if_not() of 'algorithm'. | |
template<class InputIt, class UnaryFunction> | |
constexpr UnaryFunction | jau::for_each (InputIt first, InputIt last, UnaryFunction f) |
Like std::for_each() of 'algorithm'. | |
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. | |
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() | |
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() | |
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'. | |
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. | |
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. | |
template<class ForwardIt, class T> | |
ForwardIt | jau::remove (ForwardIt first, ForwardIt last, const T &value) |
Identical to C++20 std::remove() of algorithm | |
template<class ForwardIt, class UnaryPredicate> | |
ForwardIt | jau::remove_if (ForwardIt first, ForwardIt last, UnaryPredicate p) |
Identical to C++20 std::remove_if() of algorithm | |
Basic algorithms.
|
constexprnoexcept |
Like std::find() of 'algorithm'.
Only exists here as performance analysis over O(n*n) complexity exposes std::find() to be approximately 3x slower.
See test/test_cow_darray_perf01.cpp
InputIt | the iterator type |
T | the data type |
first | range start of elements to examine |
last | range end of elements to examine, exclusive |
value | reference value for comparison |
Definition at line 104 of file basic_algos.hpp.
|
constexprnoexcept |
Return true if value
is contained in array
.
InputArray | array type |
T | value_type of value |
array | the array to search |
value | the value to search for |
Definition at line 123 of file basic_algos.hpp.
|
constexpr |
Definition at line 135 of file basic_algos.hpp.
|
constexprnoexcept |
Like std::find_if() of 'algorithm'.
Only exists here as performance analysis over O(n*n) complexity exposes std::find_if() to be approximately 3x slower for 1000 x 1000.
See test/test_cow_darray_perf01.cpp
InputIt | the iterator type |
UnaryPredicate |
first | range start of elements to examine |
last | range end of elements to examine, exclusive |
p | unary predicate which returns true for the desired element. |
Definition at line 162 of file basic_algos.hpp.
|
constexprnoexcept |
Like std::find_if_not() of 'algorithm'.
Only exists here as performance analysis over O(n*n) complexity exposes std::find_if_not() to be approximately 3x slower for 1000 x 1000.
See test/test_cow_darray_perf01.cpp
InputIt | the iterator type |
UnaryPredicate |
first | range start of elements to examine |
last | range end of elements to examine, exclusive |
q | unary predicate which returns false for the desired element. |
Definition at line 187 of file basic_algos.hpp.
ForwardIt jau::remove | ( | ForwardIt | first, |
ForwardIt | last, | ||
const T & | value ) |
Identical to C++20 std::remove() of algorithm
ForwardIt | the iterator type |
UnaryPredicate |
first | range start of elements to examine |
last | range end of elements to examine, exclusive |
value | the value to remove |
Definition at line 208 of file basic_algos.hpp.
ForwardIt jau::remove_if | ( | ForwardIt | first, |
ForwardIt | last, | ||
UnaryPredicate | p ) |
Identical to C++20 std::remove_if() of algorithm
ForwardIt | the iterator type |
UnaryPredicate |
first | range start of elements to examine |
last | range end of elements to examine, exclusive |
p | unary predicate which returns true for the desired element to be removed |
Definition at line 232 of file basic_algos.hpp.
|
constexpr |
Like std::for_each() of 'algorithm'.
Only exists here as performance analysis over O(n*n) complexity exposes std::for_each() to be 'a little' slower for 1000 x 1000.
See test/test_cow_darray_perf01.cpp
InputIt | the iterator type |
UnaryFunction |
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) |
Definition at line 260 of file basic_algos.hpp.
|
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.
InputIt | the iterator type, which might be a 'const_iterator' for non const types. |
UnaryFunction |
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) |
Definition at line 312 of file basic_algos.hpp.
|
constexpr |
Custom for_each template, same as jau::for_each but using a mutex.
Method performs UnaryFunction on all elements [first..last).
This method also utilizes a given mutex to ensure thread-safety, by operating within an RAII-style std::lock_guard block.
Definition at line 336 of file basic_algos.hpp.
|
constexpr |
Custom for_each template, using indices instead of iterators, allowing container to be modified within lambda 'callback'.
Method performs UnaryFunction on all elements [0..n-1], where n is being retrieved once before the loop!
Definition at line 355 of file basic_algos.hpp.
|
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 377 of file basic_algos.hpp.
|
noexcept |
|
noexcept |
Definition at line 403 of file basic_algos.hpp.
|
constexprnoexcept |
Definition at line 420 of file basic_algos.hpp.
|
constexprnoexcept |
Definition at line 429 of file basic_algos.hpp.
|
constexprnoexcept |
Definition at line 447 of file basic_algos.hpp.
|
constexprnoexcept |
Definition at line 459 of file basic_algos.hpp.