// file: circular_buffer/cb_wr_0.cc
//

// isip include files
//
#include "CircularBuffer.h"

// method: write_cc
//
// arguments: 
//
//  int dim: (input) dimensions of circular buffer
//  int index: (input) indicated position 
//  float_8 new_value: (input) new value that will be added in
//
// return: none
//
// this method writes a new value to the indicated position of
// circular buffer.
//
void Circular_buffer::write_cc(int dim, int index, float_8 value) {

  // note that the index is actually an offset from idx_d
  //
  int idx = idx_d[dim] + index;

  // check the index
  //
  if (idx >= size_d)
    {idx -= size_d;}
  else if (idx < (int)0)
    {idx += size_d;}

  // write the value to the corresponding position
  //
  buf_d[dim][idx] = value;
}
