Graphviz  2.41.20170921.2350
vector.h
Go to the documentation of this file.
1 /* $Id$Revision: */
2 
3 /*************************************************************************
4  * Copyright (c) 2011 AT&T Intellectual Property
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors: See CVS logs. Details at http://www.graphviz.org/
11  *************************************************************************/
12 
13 #ifndef VECTOR_H
14 #define VECTOR_H
15 #include <stdlib.h>
16 struct vector_struct {
17  int maxlen;
18  int len;
19  void *v;
20  size_t size_of_elem;
21  void (*deallocator)(void *v);
22 };
23 
24 typedef struct vector_struct *Vector;
25 
26 /* deallocator works on each element of the vector */
27 Vector Vector_new(int maxlen, size_t size_of_elem, void (*deallocator)(void *v));
28 
29 Vector Vector_add(Vector v, void *stuff);
30 
31 Vector Vector_reset(Vector v, void *stuff, int i);
32 
33 void Vector_delete(Vector v);
34 
35 void* Vector_get(Vector v, int i);
36 
37 int Vector_get_length(Vector v);
38 
39 Vector Vector_reset(Vector v, void *stuff, int i);
40 
41 /*------------- vector of strings ----------- */
42 
43 typedef Vector StringVector;
44 
45 Vector StringVector_new(int len, int delete_element_strings);
46 Vector StringVector_add(Vector v, char *i);
47 void StringVector_delete(Vector v);
48 char** StringVector_get(Vector v, int i);
49 int StringVector_get_length(Vector v);
50 Vector StringVector_reset(Vector v, char *content, int pos);
51 void StringVector_fprint(FILE *fp, StringVector v);
52 void StringVector_fprint1(FILE *fp, StringVector v);
53 StringVector StringVector_part(StringVector v, int n, int *selected_list);
54 /*------------- integer vector ----------- */
55 
56 typedef Vector IntegerVector;
57 
58 Vector IntegerVector_new(int len);
59 Vector IntegerVector_add(Vector v, int i);
60 void IntegerVector_delete(Vector v);
61 int* IntegerVector_get(Vector v, int i);
62 int IntegerVector_get_length(Vector v);
63 Vector IntegerVector_reset(Vector v, int content, int pos);
64 
65 
66 
67 #endif
int maxlen
Definition: vector.h:17
Vector IntegerVector
Definition: vector.h:56
int Vector_get_length(Vector v)
Definition: vector.c:69
void Vector_delete(Vector v)
Definition: vector.c:53
int IntegerVector_get_length(Vector v)
Definition: vector.c:99
void IntegerVector_delete(Vector v)
Definition: vector.c:88
StringVector StringVector_part(StringVector v, int n, int *selected_list)
Definition: vector.c:169
void StringVector_fprint1(FILE *fp, StringVector v)
Definition: vector.c:153
void * v
Definition: vector.h:19
Vector StringVector_reset(Vector v, char *content, int pos)
Definition: vector.c:149
Vector StringVector_add(Vector v, char *s)
Definition: vector.c:130
void * Vector_get(Vector v, int i)
Definition: vector.c:64
void(* deallocator)(void *v)
Definition: vector.h:21
int * IntegerVector_get(Vector v, int i)
Definition: vector.c:92
Vector IntegerVector_new(int len)
Definition: vector.c:80
Vector Vector_add(Vector v, void *stuff)
Definition: vector.c:43
char ** StringVector_get(Vector v, int i)
Definition: vector.c:138
Vector IntegerVector_add(Vector v, int i)
Definition: vector.c:84
Vector Vector_reset(Vector v, void *stuff, int i)
Definition: vector.c:36
Vector Vector_new(int maxlen, size_t size_of_elem, void(*deallocator)(void *v))
Definition: vector.c:18
struct vector_struct * Vector
Definition: vector.h:24
Vector StringVector_new(int len, int delete_element_strings)
Definition: vector.c:121
Vector StringVector
Definition: vector.h:43
size_t size_of_elem
Definition: vector.h:20
void StringVector_delete(Vector v)
Definition: vector.c:134
void StringVector_fprint(FILE *fp, StringVector v)
Definition: vector.c:161
int StringVector_get_length(Vector v)
Definition: vector.c:145
Vector IntegerVector_reset(Vector v, int content, int pos)
Definition: vector.c:103