tudocomp
– The TU Dortmund Compression Framework
tdc::Counter< T > Class Template Reference

A data structure for counting occurences of values of a given type T. More...

#include <Counter.hpp>

Public Types

typedef std::unordered_map< T, size_t > ranking_t
 

Public Member Functions

void increase (const T &item)
 Increase the counter for the passed value by one, setting it to 1 if it was not yet seen. More...
 
void setCount (const T &item, size_t count)
 Set the count of an item to a specific value. More...
 
size_t getCount (const T &item)
 Get the count associated with a value. More...
 
size_t getNumItems ()
 Return how many differnt values have been seen so far. More...
 
std::vector< std::pair< T, size_t > > getSorted ()
 Return a list of value-count pairs, sorted with the most-seen first. More...
 
ranking_t createRanking (size_t num=SIZE_MAX)
 Return a map of the num-most common values, keyed by their common-ness, with map[0] being hte most common one. More...
 

Detailed Description

template<class T>
class tdc::Counter< T >

A data structure for counting occurences of values of a given type T.

Definition at line 15 of file Counter.hpp.

Member Typedef Documentation

◆ ranking_t

template<class T>
typedef std::unordered_map<T, size_t> tdc::Counter< T >::ranking_t

Definition at line 20 of file Counter.hpp.

Member Function Documentation

◆ createRanking()

template<class T>
ranking_t tdc::Counter< T >::createRanking ( size_t  num = SIZE_MAX)
inline

Return a map of the num-most common values, keyed by their common-ness, with map[0] being hte most common one.

This uses the same order as getSorted().

Definition at line 75 of file Counter.hpp.

◆ getCount()

template<class T>
size_t tdc::Counter< T >::getCount ( const T &  item)
inline

Get the count associated with a value.

Definition at line 37 of file Counter.hpp.

◆ getNumItems()

template<class T>
size_t tdc::Counter< T >::getNumItems ( )
inline

Return how many differnt values have been seen so far.

Definition at line 42 of file Counter.hpp.

◆ getSorted()

template<class T>
std::vector<std::pair<T, size_t> > tdc::Counter< T >::getSorted ( )
inline

Return a list of value-count pairs, sorted with the most-seen first.

Definition at line 47 of file Counter.hpp.

◆ increase()

template<class T>
void tdc::Counter< T >::increase ( const T &  item)
inline

Increase the counter for the passed value by one, setting it to 1 if it was not yet seen.

Definition at line 24 of file Counter.hpp.

◆ setCount()

template<class T>
void tdc::Counter< T >::setCount ( const T &  item,
size_t  count 
)
inline

Set the count of an item to a specific value.

Definition at line 32 of file Counter.hpp.


The documentation for this class was generated from the following file: