From 598ab41405a8c802cacd172dd2d034b27ca5953e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 25 Jun 2021 21:57:43 -0700 Subject: [PATCH] remove unused StringVector --- lib/sparse/vector.c | 69 --------------------------------------------- lib/sparse/vector.h | 14 --------- 2 files changed, 83 deletions(-) diff --git a/lib/sparse/vector.c b/lib/sparse/vector.c index 47931b13b..9f6b19558 100644 --- a/lib/sparse/vector.c +++ b/lib/sparse/vector.c @@ -72,72 +72,3 @@ void* Vector_get(Vector v, int i){ int Vector_get_length(Vector v){ return v->len; } - -/*---------------- string vector --------------- */ - -static void strdealloactor(void *v){ - char **s = v; - free(*s); -} - -Vector StringVector_new(int len, int delete_element_strings){ - /* delete_element_strings decides whether we need to delete each string in the vector or leave it to be cleaned by other handles */ - if (!delete_element_strings){ - return Vector_new(len, sizeof(char*), NULL); - } else { - return Vector_new(len, sizeof(char*), strdealloactor); - } - -} -Vector StringVector_add(Vector v, char *s){ - return Vector_add(v, &s); -} - -void StringVector_delete(Vector v){ - return Vector_delete(v); -} - -char** StringVector_get(Vector v, int i){ - char **p = Vector_get(v, i); - if (!p) return NULL; - return p; -} - -int StringVector_get_length(Vector v){ - return Vector_get_length(v); -} - -Vector StringVector_reset(Vector v, char *content, int pos){ - return Vector_reset(v, &content, pos); -} - -void StringVector_fprint1(FILE *fp, StringVector v){ - int i; - if (!v) return; - for (i = 0; i < StringVector_get_length(v); i++){ - fprintf(fp,"%s\n", *(StringVector_get(v, i))); - } -} - -void StringVector_fprint(FILE *fp, StringVector v){ - int i; - if (!v) return; - for (i = 0; i < StringVector_get_length(v); i++){ - fprintf(fp,"%d %s\n", i+1,*(StringVector_get(v, i))); - } -} - -StringVector StringVector_part(StringVector v, int n, int *selected_list){ - /* select a list of n elements from vector v and form a new vector */ - StringVector u; - char *s, *s2; - int i; - u = StringVector_new(1, TRUE); - for (i = 0; i < n; i++){ - s = *(StringVector_get(v, selected_list[i])); - s2 = MALLOC(sizeof(char)*(strlen(s)+1)); - strcpy(s2, s); - StringVector_add(u, s2); - } - return u; -} diff --git a/lib/sparse/vector.h b/lib/sparse/vector.h index 7354911ea..4ca1fa3b6 100644 --- a/lib/sparse/vector.h +++ b/lib/sparse/vector.h @@ -36,18 +36,4 @@ int Vector_get_length(Vector v); Vector Vector_reset(Vector v, void *stuff, int i); -/*------------- vector of strings ----------- */ - -typedef Vector StringVector; - -Vector StringVector_new(int len, int delete_element_strings); -Vector StringVector_add(Vector v, char *i); -void StringVector_delete(Vector v); -char** StringVector_get(Vector v, int i); -int StringVector_get_length(Vector v); -Vector StringVector_reset(Vector v, char *content, int pos); -void StringVector_fprint(FILE *fp, StringVector v); -void StringVector_fprint1(FILE *fp, StringVector v); -StringVector StringVector_part(StringVector v, int n, int *selected_list); - #endif -- 2.40.0