xo-umbrella2/xo-distribution/include/xo/distribution/Empirical.hpp
Roland Conybeare ecd019e8bb Add 'xo-distribution/' from commit '036ca5d817'
git-subtree-dir: xo-distribution
git-subtree-mainline: 4e022df686
git-subtree-split: 036ca5d817
2025-05-11 15:52:36 -05:00

41 lines
975 B
C++

/* @file Empirical.hpp */
#pragma once
#include "xo/distribution/Distribution.hpp"
#include "xo/ordinaltree/RedBlackTree.hpp"
#include "xo/indentlog/scope.hpp"
#include <map>
#include <cstdint>
namespace xo {
namespace distribution {
/* representation for counter,
* recording #of samples with the same value
*/
using CounterRep = uint32_t;
/* counter; for use with StdEmpirical distribution below
*/
class Counter {
public:
Counter() = default;
Counter(CounterRep n) : count_(n) {}
CounterRep count() const { return count_; }
void incr() { ++count_; }
operator CounterRep () const { return count_; }
Counter & operator+=(CounterRep n) { count_ += n; return *this; }
private:
CounterRep count_ = 0;
}; /*Counter*/
} /*namespace disitribution*/
} /*namespace xo*/
/* end Empirical.hpp */