16#ifndef INCLUDE_RANS_INTERNAL_CONTAINERS_SPARSEHISTOGRAM_H_
17#define INCLUDE_RANS_INTERNAL_CONTAINERS_SPARSEHISTOGRAM_H_
26template <
typename source_T>
29 typename internal::SetContainer<source_T, uint32_t>::value_type,
30 typename internal::SetContainer<source_T, uint32_t>::difference_type,
31 SparseHistogram<source_T>>
55 template <
typename freq_IT>
64 template <
typename source_IT>
69 template <
typename freq_IT>
73template <
typename source_T>
74template <
typename source_IT>
78 absl::flat_hash_map<source_type, value_type> map;
81 std::for_each(this->mContainer.begin(),
this->mContainer.end(), [
this, &map](
const auto& keyValuePair) {
82 map.emplace(keyValuePair.first, keyValuePair.second);
86 std::for_each(begin,
end, [
this, &map](
const source_type& symbol) {
92 typename container_type::container_type mergedSymbols;
93 mergedSymbols.reserve(map.size());
94 std::for_each(map.begin(), map.end(), [&](
const auto& keyValuePair) { mergedSymbols.emplace_back(keyValuePair.first, keyValuePair.second); });
102template <
typename source_T>
103template <
typename freq_IT>
108 absl::flat_hash_map<source_type, value_type> map;
110 auto container = std::move(this->mContainer).
release();
111 for (
const auto& [
key,
value] : container) {
117 for (
auto iter = begin; iter !=
end; ++iter) {
120 auto& currentValue = map[sourceSymbol];
128 container.reserve(map.size());
129 std::for_each(map.begin(), map.end(), [&](
const auto& pair) { container.emplace_back(pair.first, pair.second); });
137template <
typename source_T>
142 return std::count_if(histogram.
begin(), histogram.
end(), [](
const auto&
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_iterator const_iterator
SparseHistogram & addFrequenciesImpl(freq_IT begin, freq_IT end, source_type offset)
SparseHistogram & addSamplesImpl(source_IT begin, source_IT end)
typename containerBase_type::const_pointer const_pointer
typename containerBase_type::container_type container_type
typename containerBase_type::reference reference
SparseHistogram()=default
typename containerBase_type::value_type value_type
typename containerBase_type::const_reference const_reference
typename containerBase_type::size_type size_type
SparseHistogram & addSamplesImpl(gsl::span< const source_type > samples)
typename containerBase_type::source_type source_type
typename containerBase_type::difference_type difference_type
typename containerBase_type::pointer pointer
SparseHistogram(freq_IT begin, freq_IT end, source_type offset)
const_iterator begin() const noexcept
container_type release() &&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::difference_type difference_type
typename base_type::const_reference const_reference
typename base_type::reference reference
typename base_type::const_pointer const_pointer
typename base_type::container_type container_type
typename base_type::value_type value_type
typename base_type::const_iterator const_iterator
typename base_type::source_type source_type
typename base_type::pointer pointer
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)