Template Function vector_split
Defined in File t8_vector_algorithms.hxx
Function Documentation
-
template<std::input_iterator TIterator, std::sentinel_for<TIterator> TSentinel, std::ranges::contiguous_range TContainer, std::unsigned_integral TCategory, typename ...Args>
constexpr void vector_split(const TIterator begin, const TSentinel end, TContainer &offsets, std::function<TCategory(const typename std::iterator_traits<TIterator>::value_type, Args...)> &&category_func, Args... args) Compute the offsets of categories of elements in a sorted iterable range given by begin and end, such as a std::vector.
The value type of the iterator should be comparable with <. The categories are defined by the std::function category_func passed as input argument. This is a re-implementation of sc_array_split.
- Template Parameters:
TIterator – An input iterator type
TSentinel – A sentinel type for the iterator
TContainer – A container type that holds the offsets. It should be a contiguous container
TCategory – The type of the category. It should be an unsigned integral type
Args – The type of the arguments passed to the category_func
- Parameters:
begin – [in] An iterator pointing to the first element of the range
end – [in] An iterator pointing to the last element of the range
offsets – [inout] A Container holding num_categories + 1 elements. Will hold indices j of the range begin and end that contain objects of category k, such that offsets[k] <0 j < offset[k+1] If there are no elements of category k then offsets[k] = offsets[k +1]
category_func – [in] A function that takes an element of the value type of the iterators begin / end and returns the category of the element. A category should be in [0, num_categories)
args – [in] A parameter pack of arguments passed to the category_func