17#ifndef INCLUDE_RANS_INTERNAL_CONTAINERS_ADAPTIVEHISTOGRAM_H_
18#define INCLUDE_RANS_INTERNAL_CONTAINERS_ADAPTIVEHISTOGRAM_H_
27template <
typename source_T>
30 typename internal::SparseVectorContainer<source_T, uint32_t>::value_type,
31 typename internal::SparseVectorContainer<source_T, uint32_t>::difference_type,
32 AdaptiveHistogram<source_T>>
56 template <
typename freq_IT>
65 template <
typename source_IT>
70 template <
typename freq_IT>
74template <
typename source_T>
75template <
typename source_IT>
79 if constexpr (std::is_same_v<typename std::iterator_traits<source_IT>::iterator_category, std::random_access_iterator_tag>) {
81 const auto size = std::distance(begin,
end);
82 constexpr size_t nUnroll = 2;
85 if (
end - nUnroll > begin) {
87 ++this->mContainer[begin[
pos + 0]];
88 ++this->mContainer[begin[
pos + 1]];
89 this->mNSamples += nUnroll;
93 for (
auto iter = begin +
pos; iter !=
end; ++iter) {
95 ++this->mContainer[*iter];
100 ++this->mContainer[symbol];
106template <
typename source_T>
107template <
typename freq_IT>
111 for (
auto iter = begin; iter !=
end; ++iter) {
114 auto& currentValue = this->mContainer[sourceSymbol];
122template <
typename source_T>
128 return std::count_if(histogram.
begin(), histogram.
end(), [](iterator_value_type
v) { return v.second != value_type{}; });
Abstract container class that defines and implements basic properties shared by histograms and lookup...
Operations that will be performed on a histogram.
common helper classes and functions
typename containerBase_type::const_pointer const_pointer
typename containerBase_type::const_reference const_reference
typename containerBase_type::source_type source_type
typename containerBase_type::pointer pointer
AdaptiveHistogram(freq_IT begin, freq_IT end, source_type offset)
AdaptiveHistogram & addFrequenciesImpl(freq_IT begin, freq_IT end, source_type offset)
typename containerBase_type::const_iterator const_iterator
typename containerBase_type::reference reference
AdaptiveHistogram & addSamplesImpl(gsl::span< const source_type > samples)
typename containerBase_type::container_type container_type
typename containerBase_type::size_type size_type
typename containerBase_type::value_type value_type
AdaptiveHistogram & addSamplesImpl(source_IT begin, source_IT end)
AdaptiveHistogram()=default
typename containerBase_type::difference_type difference_type
const_iterator begin() const noexcept
const_iterator end() const noexcept
derived_T & addFrequencies(freq_IT begin, freq_IT end, difference_type offset)
derived_T & addSamples(source_IT begin, source_IT end)
typename base_type::pointer pointer
typename base_type::difference_type difference_type
typename base_type::source_type source_type
typename base_type::const_iterator const_iterator
typename base_type::value_type value_type
typename base_type::reference reference
typename base_type::container_type container_type
typename base_type::const_pointer const_pointer
typename base_type::const_reference const_reference
typename base_type::size_type size_type
GLsizei const GLfloat * value
uint32_t safeadd(uint32_t a, uint32_t b)
size_t countNUsedAlphabetSymbols(const AdaptiveHistogram< source_T > &histogram)