8 #ifndef CIRCULAR_BUFFER_H
9 #define CIRCULAR_BUFFER_H
53 CircularBuffer(
int n_max) : size_max(n_max), size_internal(0), start(n_max), end(n_max-1) {
62 size_internal(
c.size),
q(
c.
q), start(
c.start), end(
c.end) {}
89 void get(
const unsigned int i,
T&
x)
const
93 if(
i >= size_internal ) {
98 unsigned int index = (start +
i) % size_max;
107 if(
i >= size_internal ) {
110 unsigned int index = (start +
i) % size_max;
116 if(
i >= size_internal ) {
119 unsigned int index = (start +
i) % size_max;
125 return (size_internal == 0);
134 if( size_internal == 0 ) {
156 if( size_internal+1 > size_max ) {
233 const unsigned int i;
235 const unsigned int n5;
247 CircularBufferArray(
unsigned int n_max,
unsigned int n5) : size_max(n_max), size_internal(0), start(n_max), end(n_max-1),
N5(n5) {
256 size_internal(
c.size),
q(
c.
q), start(
c.start), end(
c.end),
N5(
c.
N5) {}
279 return size_internal;
283 void get(
const unsigned int i, multi1d<T>&
x)
const
287 if(
i >= size_internal ) {
292 unsigned int index = (start +
i) % size_max;
295 for(
unsigned int s=0;
s <
N5;
s++) {
305 return (size_internal == 0);
314 if(
static_cast<int>(e.size()) !=
N5) {
315 throw SizeMismatchException(
"Attempting to push std::vector of wrong size into circular buffer",
N5, e.size());
318 if( size_internal == 0 ) {
324 for(
unsigned int s = 0;
s <
N5;
s++) {
342 if( size_internal+1 > size_max ) {
366 for(
unsigned int s = 0;
s <
N5;
s++) {
384 for(
unsigned int s = 0;
s <
N5;
s++) {
Primary include file for CHROMA library code.
Circular buffer of arrays.
int sizeMax(void) const
Get the maximum number of data items one can store.
void push(const multi1d< T > &e)
push in an item as most recent.
CircularBufferArray(const CircularBufferArray< T > &c)
Copy constructor.
bool isEmpty(void) const
Is empty check.
int size(void) const
Get the current number of items stored.
~CircularBufferArray()
Destructor is automatic.
CircularBufferArray(unsigned int n_max, unsigned int n5)
Constructor.
void get(const unsigned int i, multi1d< T > &x) const
get the ith most recent item
unsigned int size_internal
unsigned int size_internal
CircularBuffer(int n_max)
Constructor.
void replaceHead(const T &x)
int sizeMax(void) const
Get the maximum number of data items one can store.
CircularBuffer(const CircularBuffer< T > &c)
Copy constructor.
int size(void) const
Get the current number of items stored.
void get(const unsigned int i, T &x) const
get the ith most recent item
bool isEmpty(void) const
Is empty check.
void push(const T &e)
push in an item as most recent.
const T & operator[](int i) const
~CircularBuffer()
Destructor is automatic.
Asqtad Staggered-Dirac operator.
LinOpSysSolverMGProtoClover::T T
OutOfBoundsException(const std::string &s, unsigned int i_, unsigned int size_, unsigned int n5_)
const std::string error_string
const unsigned int N5_buf
const unsigned int N5_vec
SizeMismatchException(const std::string &s, unsigned int N5_buf_, unsigned int N5_vec_)
const std::string error_string
OutOfBoundsException(const std::string &s, unsigned int i_, unsigned int size_)
const std::string error_string