FORS Pipeline Reference Manual  4.12.5
list_void.h
1 /* $Id: list_void.h,v 1.10 2013-05-16 08:40:07 cgarcia Exp $
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17 
18 /*
19  * $Author: cgarcia $
20  * $Date: 2013-05-16 08:40:07 $
21  * $Revision: 1.10 $
22  * $Name: not supported by cvs2svn $
23  */
24 
25 #ifndef LIST_VOID_H
26 #define LIST_VOID_H
27 
28 #include <stdbool.h>
29 #include <stdio.h>
30 
31 typedef struct list list;
32 typedef double (*list_func_eval)(const void *element,
33  void *data);
34 
35 typedef bool (*list_func_lt)(const void *e1,
36  const void *e2,
37  void *data);
38 
39 typedef bool (*list_func_predicate)(const void *, void *);
40 
41 
42 /* Create */
43 list *list_new(void);
44 
45 list *list_duplicate(const list *l, void *(*duplicate)(const void *));
46 
47 /* Delete */
48 void
49 list_delete(list **l, void (*ldelete)(void **));
50 
51 void
52 list_delete_const(const list **l, void (*ldelete)(void **));
53 
54 int
55 list_size(const list *l);
56 
57 /* Iterate */
58 void *
59 list_first(list *l);
60 
61 void *
62 list_next(list *l);
63 
64 const void *
65 list_first_const(const list *l);
66 
67 const void *
68 list_next_const(const list *l);
69 
70 void
71 list_first_pair(list *l,
72  void **e1,
73  void **e2);
74 
75 void
76 list_next_pair(list *l,
77  void **e1,
78  void **e2);
79 
80 void
81 list_first_pair_const(const list *l,
82  const void **e1,
83  const void **e2);
84 
85 void
86 list_next_pair_const(const list *l,
87  const void **e1,
88  const void **e2);
89 
90 
91 /* Element */
92 void
93 list_insert(list *l, void *e);
94 
95 const void *
96 list_remove_const(list *l, const void *e);
97 
98 void *
99 list_remove(list *l, void *e);
100 
101 /* List */
102 void
103 list_reverse(list *l);
104 
105 list *
106 list_extract(const list *l,
107  void *(*duplicate)(const void *),
108  list_func_predicate predicate,
109  void *data);
110 
111 /* Search */
112 void *
113 list_min(list *l, list_func_lt less_than, void *data);
114 
115 void *
116 list_min_val(list *l, list_func_eval eval, void *data);
117 
118 void *
119 list_max(list *l, list_func_lt less_than, void *data);
120 
121 const void *
122 list_max_const(const list *l, list_func_lt less_than, void *data);
123 
124 void *
125 list_max_val(list *l, list_func_eval eval, void *data);
126 
127 void *
128 list_kth(list *l, int k, list_func_lt less_than, void *data);
129 
130 const void *
131 list_kth_const(const list *l, int k, list_func_lt less_than, void *data);
132 
133 void *
134 list_kth_val(list *l, int k, list_func_eval eval, void *data);
135 
136 const void *
137 list_kth_val_const(const list *l, int k, list_func_eval eval, void *data);
138 
139 /* Statistics */
140 double
141 list_mean(const list *l, list_func_eval eval, void *data);
142 
143 double
144 list_mean_optimal(const list *l,
145  list_func_eval eval, void *data_eval,
146  list_func_eval eval_err, void *data_err,
147  double *err,
148  double *red_chisq);
149 
150 double
151 list_median(const list *l, list_func_eval eval, void *data);
152 
153 double
154 list_mad(list *l, list_func_eval eval, void *data);
155 
156 #endif
list * list_duplicate(const list *l, void *(*duplicate)(const void *))
Copy constructor.
Definition: list.c:126
list * list_extract(const list *l, void *(*duplicate)(const void *), bool(*predicate)(const void *, void *), void *data)
Extract elements.
Definition: list.c:507
list * list_new(void)
Constructor.
Definition: list.c:108
Definition: list.c:74