Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tesh version 2
[simgrid.git] / tools / tesh2 / include / vector.h
1 /** 
2  * File : private/vector.h
3  *
4  * Copyright 2006,2007 Malek Cherier, Martin Quinson. All right reserved. 
5  *
6  * This program is free software; you can redistribute it and/or modify it under the terms 
7  * of the license (GNU LGPL) which comes with this package. 
8  */
9
10 #ifndef __VECTOR_H
11 #define __VECTOR_H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17
18 #ifndef __FN_FINALIZE_T_DEFINED
19 typedef int (*fn_finalize_t)(void**);
20 #define __FN_FINALIZE_T_DEFINED
21 #endif
22
23 #ifndef SEEK_SET
24 #define SEEK_SET                                0
25 #endif 
26
27 #ifndef SEEK_CUR
28 #define SEEK_CUR                                1
29 #endif
30
31 #ifndef SEEK_END
32 #define SEEK_END                                2
33 #endif
34
35 /*
36  * this type represents a vector of void* pointers.
37  */
38 typedef struct s_vector
39 {
40         int size;                               /* the number of items of the vector                                    */                                              
41         int capacity;                           /* the capacity of the vector                                           */                      
42         void** items;                           /* the items of the vector                                          */                                                          
43         fn_finalize_t fn_finalize;      /* a pointer to a function used to cleanup the elements of the vector   */
44         int pos;                                        
45 }s_vector_t,* vector_t;
46
47 vector_t
48 vector_new(int capacity,fn_finalize_t fn_finalize);
49
50 int 
51 vector_clear(vector_t vector);
52
53 int
54 vector_free(vector_t* vector_ptr);
55
56 int
57 vector_is_empty(vector_t vector);
58
59 void*
60 vector_get_at(vector_t vector, int pos);
61
62 int 
63 vector_get_size(vector_t vector);
64
65 void*
66 vector_get_front(vector_t vector);
67
68 void*
69 vector_get_back(vector_t vector);
70
71 int
72 vector_get_capacity_available(vector_t vector);
73
74 int
75 vector_push_back(vector_t vector, void* item);
76
77 void*
78 vector_pop_back(vector_t vector);
79
80 int
81 vector_get_upper_bound(vector_t vector);
82
83 void*
84 vector_set_at(vector_t vector, int index, void* item);
85
86 int 
87 vector_insert(vector_t vector, int index, void* item);
88
89 int
90 vector_erase_at(vector_t vector, int index);
91
92 int 
93 vector_erase(vector_t vector, void* item);
94
95 int
96 vector_erase_range(vector_t vector, int first, int last);
97
98 int 
99 vector_remove(vector_t vector, void* item);
100
101 int
102 vector_search(vector_t vector, void* item);
103
104 int
105 vector_assign(vector_t dst,vector_t src);
106
107 int
108 vector_get_capacity(vector_t vector);
109
110 int
111 vector_equals(vector_t vector, vector_t other);
112
113 int
114 vector_swap(vector_t vector, vector_t other);
115
116 vector_t
117 vector_clone(vector_t vector);
118
119 int
120 vector_contains(vector_t vector,void* item);
121
122 int
123 vector_reserve(vector_t vector,int size);
124
125 int
126 vector_is_autodelete(vector_t vector);
127
128 int
129 vector_has_capacity_available(vector_t vector);
130
131 int
132 vector_is_full(vector_t vector);
133
134 int
135 vector_get_max_index(vector_t vector);
136
137 void*
138 vector_get(vector_t vector);
139
140 void*
141 vector_get_at(vector_t vector, int pos);
142
143 int
144 vector_getpos(vector_t vector, int* pos);
145
146 int
147 vector_move_next(vector_t vector);
148
149 int
150 vector_move_prev(vector_t vector);
151
152 int
153 vector_rewind(vector_t vector);
154
155 int
156 vector_seek(vector_t vector, int offset, int whence);
157
158 void*
159 vector_set(vector_t vector, void* item);
160
161 int
162 vector_setpos(vector_t vector, int pos);
163
164 int
165 vector_tell(vector_t vector);
166
167 int
168 vector_unwind(vector_t vector);
169
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif /* !XBT_PRIVATE_VECTOR_PTR_H */