9511_project03

project 3 for algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README LICENSE
include/vector.h (1217B)
   1 #ifndef VECTOR__H
   2 #define VECTOR__H
   3 
   4 #include <stdlib.h>
   5 
   6 #include "status.h"
   7 
   8 #define VECTOR_INIT_SIZE        10
   9 #define VECTOR_GROWTH_FACTOR    2
  10 
  11 #define XML_STR_HEADER    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  12 #define XML_STR_ROOT    "root"
  13 #define XML_STR_ROW        "row"
  14 
  15 typedef status_t (*printer_t)(const void *, FILE *);
  16 typedef int (*comparator_t)(const void *, const void *);
  17 
  18 typedef struct {
  19     void **a;
  20     size_t size, alloc;
  21 
  22     printer_t printer;
  23     comparator_t comparator;
  24 
  25 } ADT_Vector_t;
  26 
  27 status_t ADT_Vector_create(ADT_Vector_t **);
  28 status_t ADT_Vector_add(ADT_Vector_t **, void *);
  29 status_t ADT_Vector_destroy(ADT_Vector_t **);
  30 
  31 status_t ADT_Vector_print(const ADT_Vector_t *, FILE *);
  32 status_t ADT_Vector_sort(ADT_Vector_t *, comparator_t);
  33 
  34 status_t ADT_Vector_set_elem(ADT_Vector_t **, void *, size_t);
  35 status_t ADT_Vector_get_elem(const ADT_Vector_t *, void **, size_t);
  36 status_t ADT_Vector_get_elem_pos(const ADT_Vector_t *, void *, size_t *);
  37 
  38 status_t ADT_Vector_set_printer(ADT_Vector_t *, printer_t);
  39 status_t ADT_Vector_set_comparator(ADT_Vector_t *, comparator_t);
  40 
  41 status_t ADT_Vector_export_as_xml(const ADT_Vector_t *, FILE *);
  42 status_t ADT_Vector_export_as_csv(const ADT_Vector_t *, FILE *);
  43 
  44 #endif