FORS Pipeline Reference Manual 4.9.9
|
00001 /* $Id: list_void.h,v 1.9 2009/02/17 15:23:51 hlorch Exp $ 00002 * 00003 * This program is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00016 */ 00017 00018 /* 00019 * $Author: hlorch $ 00020 * $Date: 2009/02/17 15:23:51 $ 00021 * $Revision: 1.9 $ 00022 * $Name: fors-4_9_9 $ 00023 */ 00024 00025 #ifndef LIST_VOID_H 00026 #define LIST_VOID_H 00027 00028 #include <stdbool.h> 00029 #include <stdio.h> 00030 00031 typedef struct list list; 00032 typedef double (*list_func_eval)(const void *element, 00033 void *data); 00034 00035 typedef bool (*list_func_lt)(const void *e1, 00036 const void *e2, 00037 void *data); 00038 00039 typedef bool (*list_func_predicate)(const void *, void *); 00040 00041 00042 /* Create */ 00043 list *list_new(void); 00044 00045 list *list_duplicate(const list *l, void *(*duplicate)(const void *)); 00046 00047 /* Delete */ 00048 void 00049 list_delete(list **l, void (*delete)(void **)); 00050 00051 void 00052 list_delete_const(const list **l, void (*delete)(void **)); 00053 00054 int 00055 list_size(const list *l); 00056 00057 /* Iterate */ 00058 void * 00059 list_first(list *l); 00060 00061 void * 00062 list_next(list *l); 00063 00064 const void * 00065 list_first_const(const list *l); 00066 00067 const void * 00068 list_next_const(const list *l); 00069 00070 void 00071 list_first_pair(list *l, 00072 void **e1, 00073 void **e2); 00074 00075 void 00076 list_next_pair(list *l, 00077 void **e1, 00078 void **e2); 00079 00080 void 00081 list_first_pair_const(const list *l, 00082 const void **e1, 00083 const void **e2); 00084 00085 void 00086 list_next_pair_const(const list *l, 00087 const void **e1, 00088 const void **e2); 00089 00090 00091 /* Element */ 00092 void 00093 list_insert(list *l, void *e); 00094 00095 const void * 00096 list_remove_const(list *l, const void *e); 00097 00098 void * 00099 list_remove(list *l, void *e); 00100 00101 /* List */ 00102 void 00103 list_reverse(list *l); 00104 00105 list * 00106 list_extract(const list *l, 00107 void *(*duplicate)(const void *), 00108 list_func_predicate predicate, 00109 void *data); 00110 00111 /* Search */ 00112 void * 00113 list_min(list *l, list_func_lt less_than, void *data); 00114 00115 void * 00116 list_min_val(list *l, list_func_eval eval, void *data); 00117 00118 void * 00119 list_max(list *l, list_func_lt less_than, void *data); 00120 00121 const void * 00122 list_max_const(const list *l, list_func_lt less_than, void *data); 00123 00124 void * 00125 list_max_val(list *l, list_func_eval eval, void *data); 00126 00127 void * 00128 list_kth(list *l, int k, list_func_lt less_than, void *data); 00129 00130 const void * 00131 list_kth_const(const list *l, int k, list_func_lt less_than, void *data); 00132 00133 void * 00134 list_kth_val(list *l, int k, list_func_eval eval, void *data); 00135 00136 const void * 00137 list_kth_val_const(const list *l, int k, list_func_eval eval, void *data); 00138 00139 /* Statistics */ 00140 double 00141 list_mean(const list *l, list_func_eval eval, void *data); 00142 00143 double 00144 list_mean_optimal(const list *l, 00145 list_func_eval eval, void *data_eval, 00146 list_func_eval eval_err, void *data_err, 00147 double *err, 00148 double *red_chisq); 00149 00150 double 00151 list_median(const list *l, list_func_eval eval, void *data); 00152 00153 double 00154 list_mad(list *l, list_func_eval eval, void *data); 00155 00156 #endif