31#ifndef ETL_HISTOGRAM_INCLUDED
32#define ETL_HISTOGRAM_INCLUDED
39#include "static_assert.h"
45 namespace private_histogram
50 template <
typename TCount,
size_t Max_Size_>
57 static ETL_CONSTANT
size_t Max_Size =
Max_Size_;
66 return accumulator.
begin();
74 return accumulator.
cbegin();
82 return accumulator.
end();
90 return accumulator.cend();
104 ETL_CONSTEXPR
size_t size()
const
130 template <
typename TCount,
size_t Max_Size_>
131 ETL_CONSTANT
size_t histogram_common<TCount, Max_Size_>::Max_Size;
137 template <typename TKey, typename TCount, size_t Max_Size, int32_t Start_Index = etl::integral_limits<int32_t>::max>
162 template <
typename TIterator>
174 this->accumulator =
other.accumulator;
183 this->accumulator = etl::move(
other.accumulator);
192 this->accumulator =
rhs.accumulator;
203 this->accumulator = etl::move(
rhs.accumulator);
220 template <
typename TIterator>
223 while (first != last)
241 template <
typename TIterator>
259 template<
typename TKey,
typename TCount,
size_t Max_Size>
285 template <
typename TIterator>
298 this->accumulator =
other.accumulator;
307 this->accumulator = etl::move(
other.accumulator);
316 this->accumulator =
rhs.accumulator;
327 this->accumulator = etl::move(
rhs.accumulator);
338 ++this->accumulator[key - start_index];
344 template <
typename TIterator>
347 while (first != last)
365 template <
typename TIterator>
376 return this->accumulator[key - start_index];
381 key_type start_index;
387 template<
typename TKey,
typename TCount,
size_t Max_Size_>
398 static ETL_CONSTANT
size_t Max_Size =
Max_Size_;
400 typedef TKey key_type;
401 typedef TCount count_type;
402 typedef typename accumulator_type::value_type value_type;
403 typedef typename accumulator_type::const_iterator const_iterator;
417 template <
typename TIterator>
428 this->accumulator =
other.accumulator;
437 accumulator = etl::move(
other.accumulator);
446 accumulator =
rhs.accumulator;
457 accumulator = etl::move(
rhs.accumulator);
468 return accumulator.
begin();
476 return accumulator.
cbegin();
482 const_iterator
end()
const
484 return accumulator.
begin();
492 return accumulator.
cbegin();
498 void add(
const key_type& key)
506 template <
typename TIterator>
509 while (first != last)
527 template <
typename TIterator>
538 static const value_type
unused(key_type(), count_type(0));
540 typename accumulator_type::const_iterator itr = accumulator.
find(key);
542 if (itr != accumulator.
end())
565 return accumulator.
size();
581 count_type sum = count_type(0);
583 const_iterator itr = accumulator.
begin();
585 while (itr != accumulator.
end())
587 sum += (*itr).second;
599 template <
typename TKey,
typename TCount,
size_t Max_Size_>
600 ETL_CONSTANT
size_t sparse_histogram<TKey, TCount, Max_Size_>::Max_Size;
histogram(key_type start_index_, TIterator first, TIterator last)
Constructor.
Definition histogram.h:286
void add(key_type key)
Add.
Definition histogram.h:336
histogram(key_type start_index_)
Constructor.
Definition histogram.h:276
void add(TIterator first, TIterator last)
Add.
Definition histogram.h:345
histogram(const histogram &other)
Copy constructor.
Definition histogram.h:296
Histogram with a compile time start index.
Definition histogram.h:141
void operator()(key_type key)
operator ()
Definition histogram.h:233
void add(key_type key)
Add.
Definition histogram.h:212
value_type operator[](key_type key) const
operator []
Definition histogram.h:250
void add(TIterator first, TIterator last)
Add.
Definition histogram.h:221
histogram(TIterator first, TIterator last)
Constructor.
Definition histogram.h:163
histogram()
Constructor.
Definition histogram.h:154
histogram & operator=(const histogram &rhs)
Copy assignment.
Definition histogram.h:190
histogram(const histogram &other)
Copy constructor.
Definition histogram.h:172
Base for histograms.
Definition histogram.h:52
const_iterator end() const
End of the histogram.
Definition histogram.h:80
const_iterator cend() const
End of the histogram.
Definition histogram.h:88
const_iterator cbegin() const
Beginning of the histogram.
Definition histogram.h:72
size_t count() const
Count of items in the histogram.
Definition histogram.h:120
const_iterator begin() const
Beginning of the histogram.
Definition histogram.h:64
void clear()
Clear the histogram.
Definition histogram.h:96
ETL_CONSTEXPR size_t size() const
Size of the histogram.
Definition histogram.h:104
ETL_CONSTEXPR size_t max_size() const
Max size of the histogram.
Definition histogram.h:112
Histogram for sparse keys.
Definition histogram.h:389
ETL_CONSTEXPR size_t max_size() const
Max size of the histogram.
Definition histogram.h:571
const_iterator begin() const
Beginning of the histogram.
Definition histogram.h:466
sparse_histogram(const sparse_histogram &other)
Copy constructor.
Definition histogram.h:426
const_iterator end() const
End of the histogram.
Definition histogram.h:482
void clear()
Clear the histogram.
Definition histogram.h:555
void add(TIterator first, TIterator last)
Add.
Definition histogram.h:507
const value_type & operator[](const key_type &key) const
operator []
Definition histogram.h:536
const_iterator cbegin() const
Beginning of the histogram.
Definition histogram.h:474
void operator()(const key_type &key)
operator ()
Definition histogram.h:519
sparse_histogram & operator=(const sparse_histogram &rhs)
Copy assignment.
Definition histogram.h:444
size_t size() const
Size of the histogram.
Definition histogram.h:563
sparse_histogram(TIterator first, TIterator last)
Constructor.
Definition histogram.h:418
sparse_histogram()
Constructor.
Definition histogram.h:410
void add(const key_type &key)
Add.
Definition histogram.h:498
const_iterator cend() const
End of the histogram.
Definition histogram.h:490
size_t count() const
Count of items in the histogram.
Definition histogram.h:579
ETL_CONSTEXPR14 T accumulate(TIterator first, TIterator last, T sum)
Definition algorithm.h:2114
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:228
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition array.h:374
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:256
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:246
iterator begin()
Definition flat_map.h:128
void clear()
Clears the flat_map.
Definition flat_map.h:685
iterator find(const_key_reference key)
Definition flat_map.h:712
const_iterator cbegin() const
Definition flat_map.h:164
iterator end()
Definition flat_map.h:146
size_type size() const
Definition flat_map.h:924
Definition integral_limits.h:516
is_integral
Definition type_traits_generator.h:1001
bitset_ext
Definition absolute.h:38
pair holds two objects of arbitrary type
Definition utility.h:164
Definition functional.h:118