/*
   File:        amcv.h
   Author:      Scott Davies
*/

#ifndef AMCV_H
#define AMCV_H

#include <stdio.h>
#include <math.h>
#include <limits.h>

#include "ambs.h"      /* Very basic operations */
#include "amma.h"      /* Fast, non-fragmenting, memory management */
#include "amar.h"      /* Obvious operations on 1-d arrays */

typedef struct cvec_struct
{
  int cvec_code;
  int array_size;
  int size;
  char *carr;
} cvec, *cvec_ptr;

cvec *mk_cvec(int size);
void free_cvec(cvec *cv);

char safe_cvec_ref(cvec* cv, int i);
void safe_cvec_set(cvec* cv, int i, char value);

/*char cvec_ref(cvec *cv, int i);*/
/*void cvec_set(cvec *cv,int i,char value);*/
#ifdef AMFAST
#define cvec_ref(v, i) ((v)->carr[i])
#define cvec_set(v, i, j) ((v)->carr[i] = j)
#else
#define cvec_ref(v, i) safe_cvec_ref(v, i)
#define cvec_set(v, i, j) safe_cvec_set(v, i, j)
#endif

void cvec_increment(cvec *cv,int i,char value);
int cvec_size(cvec *cv);
void constant_cvec(cvec *cv,char value);
cvec *mk_constant_cvec(int size,char value);
void copy_cvec(cvec *cv,cvec *r_cv);
cvec *mk_copy_cvec(cvec *cv);

#endif
