liba2ri  0.2
 All Data Structures
util.h
1 /*************************************/
2 /* Auteur : Rémi Synave */
3 /* Date de création : 01/03/07 */
4 /* Date de modification : 08/01/10 */
5 /* Version : 0.2 */
6 /*************************************/
7 
8 /***************************************************************************/
9 /* This file is part of a2ri. */
10 /* */
11 /* a2ri is free software: you can redistribute it and/or modify it */
12 /* under the terms of the GNU Lesser General Public License as published */
13 /* by the Free Software Foundation, either version 3 of the License, or */
14 /* (at your option) any later version. */
15 /* */
16 /* a2ri is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public */
22 /* License along with a2ri. */
23 /* If not, see <http://www.gnu.org/licenses/>. */
24 /***************************************************************************/
25 
26 
27 
28 #ifndef UTIL__H
29 #define UTIL__H
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include <sys/time.h>
35 #include "config.h"
36 #include "debug.h"
37 
38 #define WITH_REDUNDANCE 0
39 #define WITHOUT_REDUNDANCE 1
40 #define ASC 0
41 #define DESC 1
42 
43 #define egalite(val1,val2) (val1>=val2-A2RI_PRECISION_FLOAT && val1<=val2+A2RI_PRECISION_FLOAT)
44 
45 typedef struct timeval a2ri_time;
46 
53 void a2ri_erreur_critique_si (
54  int cond,
55  char *str);
56 
63 int rand_int (
64  int min,
65  int max);
66 
74 int list_int_contains (
75  int *list,
76  int size,
77  int tosearch);
78 
86 int list_double_contains (
87  double *list,
88  int size,
89  double tosearch);
90 
98 int list_int_clone (
99  int *list,
100  int size,
101  int **list_clone);
102 
110 int list_double_clone (
111  double *list,
112  int size,
113  double **list_clone);
114 
125 void list_int_intersection (
126  int *list1,
127  int size1,
128  int *list2,
129  int size2,
130  int **list_inter,
131  int *size_list_inter);
132 
141 int list_int_add (
142  int **list,
143  int *size,
144  int toadd,
145  int add_type);
146 
155 int list_double_add (
156  double **list,
157  int *size,
158  double toadd,
159  int add_type);
160 
168 int list_int_remove (
169  int **list,
170  int *size,
171  int index);
172 
180 int list_double_remove (
181  double **list,
182  int *size,
183  int index);
184 
185 
192 void list_int_mix (
193  int *list,
194  int size);
195 
202 void list_double_mix (
203  double *list,
204  int size);
205 
212 void list_int_display (
213  int *list,
214  int size);
215 
222 void list_double_display (
223  double *list,
224  int size);
225 
232 void list_int_reverse (
233  int *list,
234  int size);
235 
242 void list_double_reverse (
243  double *list,
244  int size);
245 
253 void list_int_shift_right (
254  int *list,
255  int size,
256  int shift);
257 
265 void list_int_shift_left (
266  int *list,
267  int size,
268  int shift);
269 
277 void list_double_shift_right (
278  double *list,
279  int size,
280  int shift);
281 
289 void list_double_shift_left (
290  double *list,
291  int size,
292  int shift);
293 
300 int list_int_min (
301  int *list,
302  int size);
303 
310 int list_int_max (
311  int *list,
312  int size);
313 
320 double list_double_min (
321  double *list,
322  int size);
323 
330 double list_double_max (
331  double *list,
332  int size);
333 
340 double list_int_average (
341  int *list,
342  int size);
343 
350 double list_int_variance (
351  int *list,
352  int size);
353 
360 double list_double_average (
361  double *list,
362  int size);
363 
370 double list_double_variance (
371  double *list,
372  int size);
373 
381 void list_int_sort (
382  int *list,
383  int size,
384  int type);
385 
393 void list_double_sort (
394  double *list,
395  int size,
396  int type);
397 
403 void a2ri_time_init (
404  a2ri_time * t);
405 
411 a2ri_time a2ri_get_time (
412  );
413 
420 double a2ri_time_interval_to_double (
421  a2ri_time deb,
422  a2ri_time fin);
423 
430 void a2ri_display_interval_time (
431  char *str,
432  a2ri_time deb,
433  a2ri_time fin);
434 
435 #endif