1 #ifndef NPSTAT_CIRCULARBUFFER_HH_
2 #define NPSTAT_CIRCULARBUFFER_HH_
23 typename Precise=
typename PreciseType<Numeric>::type
32 inline unsigned long size()
const {
return len_;}
35 inline unsigned long nFills()
const {
return nfills_;}
42 inline const Numeric&
at(
const unsigned long i)
const
43 {
return data_.at((nfills_ + i) % len_);}
45 inline Numeric&
at(
const unsigned long i)
46 {
return data_.at((nfills_ + i) % len_);}
54 inline const Numeric&
operator[](
const unsigned long i)
const
55 {
return data_[(nfills_ + i) % len_];}
57 inline Numeric&
operator[](
const unsigned long i)
58 {
return data_[(nfills_ + i) % len_];}
62 inline bool empty()
const {
return !nfills_;}
65 inline bool filled()
const {
return nfills_ >= len_;}
82 inline void reset() {data_.clear(); nfills_ = 0;}
105 std::vector<Numeric> data_;
107 unsigned long nfills_;
111 #include "npstat/stat/CircularBuffer.icc"
Compile-time deduction of an appropriate precise numeric type.
Definition: CircularBuffer.hh:26
CircularBuffer(unsigned long sz)
const Numeric & operator[](const unsigned long i) const
Definition: CircularBuffer.hh:54
void reset()
Definition: CircularBuffer.hh:82
bool filled() const
Definition: CircularBuffer.hh:65
bool operator==(const CircularBuffer &r) const
const Numeric & at(const unsigned long i) const
Definition: CircularBuffer.hh:42
void accumulate(const Numeric &value)
unsigned long nFills() const
Definition: CircularBuffer.hh:35
bool empty() const
Definition: CircularBuffer.hh:62
bool operator!=(const CircularBuffer &r) const
unsigned long size() const
Definition: CircularBuffer.hh:32
Precise meanUncertainty() const
Definition: AbsArrayProjector.hh:14