/*
   File:        dyvp_array.h
   Author:      Dan Pelleg
   Created:     Mon Jan 19 11:46:33 EST 2004
   Description: Header for dyvp_array

   Copyright 2004, Carnegie Mellon University
*/

#ifndef DYVP_ARRAY_H
#define DYVP_ARRAY_H

#include "amdyv.h"

/* dyvp_array stuff
   a dyvp_array is a kind of dyv_array which does not 
   "own" its dyvs. That is, it simply stores pointers
   to dyvs which someone else needs to allocate and free.
*/

typedef struct dyvp_array
{
  int size;
  int array_size;
  const dyv **array;
} dyvp_array;

dyvp_array *mk_empty_dyvp_array(void);
void add_to_dyvp_array(dyvp_array *pda, const dyv *dv);

void free_dyvp_array(dyvp_array *pda);

const dyv *safe_dyvp_array_ref(const dyvp_array *pda,int idx);

#ifdef AMFAST
#define dyvp_array_ref(dva,i) ((dva)->array[i])
#else
#define dyvp_array_ref(dva,i) safe_dyvp_array_ref(dva,i)
#endif

int dyvp_array_size(const dyvp_array *da);

dyvp_array *mk_dyvp_array( int size);

void dyvp_array_set(dyvp_array *dva, int idx, const dyv *dv);

#endif /* #ifndef DYVP_ARRAY_H */
