list.h

00001 /* $Id: list.h,v 1.10 2013-05-16 08:40:07 cgarcia 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: cgarcia $
00020  * $Date: 2013-05-16 08:40:07 $
00021  * $Revision: 1.10 $
00022  * $Name: not supported by cvs2svn $
00023  */
00024 
00025 #ifndef LIST_ELEM
00026 #error Define LIST_ELEM before including
00027 #endif
00028 
00029 #include <cpl.h>
00030 #include <list_void.h>
00031 #include <stdio.h>
00032 
00033 #define LIST_CON(a,b) a ## _ ## b
00034 #define LIST_CAT(a,b) LIST_CON(a,b)
00035 
00036 #define LIST LIST_CAT(LIST_ELEM, list)
00037 
00038 #ifndef LIST_DEFINE
00039 
00040 typedef struct LIST LIST;
00041 
00042 typedef double (*LIST_CAT(LIST, func_eval))(const LIST_ELEM *,
00043                         void *);
00044 
00045 typedef bool (*LIST_CAT(LIST, func_lt))(const LIST_ELEM *,
00046                     const LIST_ELEM *,
00047                     void *);
00048 
00049 typedef bool (*LIST_CAT(LIST, func_predicate))(const LIST_ELEM *,
00050                            void *);
00051 
00052 #endif
00053 
00054 CPL_BEGIN_DECLS
00055 
00056 LIST *
00057 LIST_CAT(LIST, new)(void) 
00058 #ifdef LIST_DEFINE 
00059 {
00060   return (LIST *) list_new();
00061 }
00062 #else
00063 ;
00064 #endif
00065 
00066 
00067 LIST *
00068 LIST_CAT(LIST, duplicate)(const LIST *l,
00069               LIST_ELEM * (*duplicate)(const LIST_ELEM *))
00070 #ifdef LIST_DEFINE 
00071 {
00072     return (LIST *) 
00073         list_duplicate((const list *)l,
00074                        (void *(*)(const void *)) duplicate);
00075 }
00076 #else
00077 ;
00078 #endif
00079 
00080 void
00081 LIST_CAT(LIST, delete)(LIST **l,
00082                                  void (*ldelete)(LIST_ELEM **))
00083 #ifdef LIST_DEFINE 
00084 {
00085   list_delete((list **)l, (void (*)(void **))ldelete);
00086 }
00087 #else
00088 ;
00089 #endif
00090 
00091 void
00092 LIST_CAT(LIST, delete_const)(const LIST **l,
00093                  void (*ldelete)(LIST_ELEM **))
00094 #ifdef LIST_DEFINE 
00095 {
00096     list_delete_const((const list **)l, (void (*)(void **))ldelete);
00097 }
00098 #else
00099 ;
00100 #endif
00101 
00102 void
00103 LIST_CAT(LIST, insert)(LIST *l, LIST_ELEM *e)
00104 #ifdef LIST_DEFINE 
00105 {
00106   list_insert((list *)l, e);
00107 }
00108 #else
00109 ;
00110 #endif
00111 
00112 void
00113 LIST_CAT(LIST, reverse)(LIST *l)
00114 #ifdef LIST_DEFINE 
00115 {
00116   list_reverse((list *)l);
00117 }
00118 #else
00119 ;
00120 #endif
00121 
00122 int
00123 LIST_CAT(LIST, size)(const LIST *l)
00124 #ifdef LIST_DEFINE 
00125 {
00126     return list_size((const list *)l);
00127 }
00128 #else
00129 ;
00130 #endif
00131 
00132 
00133 LIST_ELEM *
00134 LIST_CAT(LIST, first)(LIST *l)
00135 #ifdef LIST_DEFINE 
00136 {
00137   return (LIST_ELEM*)list_first((list *)l);
00138 }
00139 #else
00140 ;
00141 #endif
00142 
00143 
00144 LIST_ELEM *
00145 LIST_CAT(LIST, next)(LIST *l)
00146 #ifdef LIST_DEFINE 
00147 {
00148   return (LIST_ELEM*)list_next((list *)l);
00149 }
00150 #else
00151 ;
00152 #endif
00153 
00154 
00155 const LIST_ELEM *
00156 LIST_CAT(LIST, first_const)(const LIST *l)
00157 #ifdef LIST_DEFINE 
00158 {
00159   return (const LIST_ELEM*)list_first_const((list *)l);
00160 }
00161 #else
00162 ;
00163 #endif
00164 
00165 
00166 const LIST_ELEM *
00167 LIST_CAT(LIST, next_const)(const LIST *l)
00168 #ifdef LIST_DEFINE 
00169 {
00170     return (const LIST_ELEM*)list_next_const((const list *)l);
00171 }
00172 #else
00173 ;
00174 #endif
00175 
00176 void
00177 LIST_CAT(LIST, first_pair)(LIST *l, 
00178                      LIST_ELEM **e1,
00179                      LIST_ELEM **e2)
00180 #ifdef LIST_DEFINE 
00181 {
00182     list_first_pair((list *)l, (void **)e1, (void **)e2);
00183     return;
00184 }
00185 #else
00186 ;
00187 #endif
00188 
00189 void
00190 LIST_CAT(LIST, next_pair)(LIST *l, 
00191                     LIST_ELEM **e1,
00192                     LIST_ELEM **e2)
00193 #ifdef LIST_DEFINE 
00194 {
00195     list_next_pair((list *)l, (void **)e1, (void **)e2);
00196     return;
00197 }
00198 #else
00199 ;
00200 #endif
00201 
00202 void
00203 LIST_CAT(LIST, first_pair_const)(const LIST *l, 
00204                        const LIST_ELEM **e1,
00205                        const LIST_ELEM **e2)
00206 #ifdef LIST_DEFINE 
00207 {
00208     list_first_pair((list *)l, (void **)e1, (void **)e2);
00209     return;
00210 }
00211 #else
00212 ;
00213 #endif
00214 void
00215 LIST_CAT(LIST, next_pair_const)(const LIST *l, 
00216                       const LIST_ELEM **e1,
00217                       const LIST_ELEM **e2)
00218 #ifdef LIST_DEFINE 
00219 {
00220     list_next_pair((list *)l, (void **)e1, (void **)e2);
00221     return;
00222 }
00223 #else
00224 ;
00225 #endif
00226 
00227 const LIST_ELEM *
00228 LIST_CAT(LIST, remove_const)(LIST *l, const LIST_ELEM *e)
00229 #ifdef LIST_DEFINE 
00230 {
00231     return (const LIST_ELEM*)list_remove_const((list *)l, e);
00232 }
00233 #else
00234 ;
00235 #endif
00236 
00237 LIST_ELEM *
00238 LIST_CAT(LIST, remove)(LIST *l, LIST_ELEM *e)
00239 #ifdef LIST_DEFINE 
00240 {
00241     return (LIST_ELEM*)list_remove((list *)l, e);
00242 }
00243 #else
00244 ;
00245 #endif
00246 
00247 
00248 LIST *
00249 LIST_CAT(LIST, extract)(const LIST *l,
00250             LIST_ELEM * (*duplicate)(const LIST_ELEM *),
00251             LIST_CAT(LIST, func_predicate) predicate,
00252             void *data)
00253 #ifdef LIST_DEFINE 
00254 {
00255     return (LIST *)list_extract((const list *)l,
00256                 (void *(*)(const void *))duplicate,
00257                 (list_func_predicate) predicate,
00258                 data);
00259 }
00260 #else
00261 ;
00262 #endif
00263 
00264 
00265 const LIST_ELEM *
00266 LIST_CAT(LIST, max_const)(const LIST *l,
00267               LIST_CAT(LIST, func_lt) less_than,
00268               void *data)
00269 #ifdef LIST_DEFINE
00270 {
00271     return (const LIST_ELEM*)list_max_const((list *)l, 
00272                           (list_func_lt) less_than,
00273                           data);
00274 }
00275 #else
00276 ;
00277 #endif
00278 
00279 LIST_ELEM *
00280 LIST_CAT(LIST, max)(LIST *l,
00281             LIST_CAT(LIST, func_lt) less_than,
00282             void *data)
00283 #ifdef LIST_DEFINE
00284 {
00285     return (LIST_ELEM*)list_max((list *)l, 
00286                     (list_func_lt) less_than,
00287                     data);
00288 }
00289 #else
00290 ;
00291 #endif
00292 
00293 LIST_ELEM *
00294 LIST_CAT(LIST, min)(LIST *l,
00295             LIST_CAT(LIST, func_lt) less_than,
00296             void *data)
00297 #ifdef LIST_DEFINE
00298 {
00299     return (LIST_ELEM*)list_min((list *)l,
00300                     (list_func_lt) less_than,
00301                     data);
00302 }
00303 #else
00304 ;
00305 #endif
00306 
00307 
00308 LIST_ELEM *
00309 LIST_CAT(LIST, min_val)(LIST *l,
00310             LIST_CAT(LIST, func_eval) eval,
00311             void *data)
00312 #ifdef LIST_DEFINE
00313 {
00314     return (LIST_ELEM*)list_min_val((list *)l,
00315             (list_func_eval) eval,
00316             data);
00317 }
00318 #else
00319 ;
00320 #endif
00321 
00322 
00323 LIST_ELEM *
00324 LIST_CAT(LIST, max_val)(LIST *l,
00325             LIST_CAT(LIST, func_eval) eval,
00326             void *data)
00327 #ifdef LIST_DEFINE
00328 {
00329     return (LIST_ELEM*)list_max_val((list *)l,
00330             (list_func_eval) eval,
00331             data);
00332 }
00333 #else
00334 ;
00335 #endif
00336 
00337 
00338 const LIST_ELEM *
00339 LIST_CAT(LIST, kth_const)(const LIST *l, int k,
00340               LIST_CAT(LIST, func_lt) less_than,
00341               void *data)
00342 #ifdef LIST_DEFINE
00343 {
00344   return (const LIST_ELEM*)list_kth_const((list *)l, k,
00345             (list_func_lt) less_than,
00346                         data);
00347 }
00348 #else
00349 ;
00350 #endif
00351 
00352 LIST_ELEM *
00353 LIST_CAT(LIST, kth)(LIST *l, int k,
00354             LIST_CAT(LIST, func_lt) less_than,
00355             void *data)
00356 #ifdef LIST_DEFINE
00357 {
00358     return (LIST_ELEM*)list_kth((list *)l, k,
00359             (list_func_lt) less_than,
00360                     data);
00361 }
00362 #else
00363 ;
00364 #endif
00365 
00366 
00367 LIST_ELEM *
00368 LIST_CAT(LIST, kth_val)(LIST *l, int k,
00369             LIST_CAT(LIST, func_eval) eval, 
00370             void *data)
00371 #ifdef LIST_DEFINE
00372 {
00373     return (LIST_ELEM*)list_kth_val((list *)l, k,
00374             (list_func_eval) eval,
00375             data);
00376 }
00377 #else
00378 ;
00379 #endif
00380 
00381 
00382 
00383 const LIST_ELEM *
00384 LIST_CAT(LIST, kth_val_const)(const LIST *l, int k,
00385                   LIST_CAT(LIST, func_eval) eval, 
00386                   void *data)
00387 #ifdef LIST_DEFINE
00388 {
00389     return (const LIST_ELEM*)list_kth_val_const((const list *)l, k,
00390                   (list_func_eval) eval,
00391                   data);
00392 }
00393 #else
00394 ;
00395 #endif
00396 
00397 
00398 
00399 
00400 double
00401 LIST_CAT(LIST, mean)(LIST *l,
00402              LIST_CAT(LIST, func_eval) eval,
00403              void *data)
00404 #ifdef LIST_DEFINE
00405 {
00406     return list_mean((list *)l,
00407              (list_func_eval) eval,
00408              data);
00409 }
00410 #else
00411 ;
00412 #endif
00413 
00414 double
00415 LIST_CAT(LIST, mean_optimal)(LIST *l,
00416                  LIST_CAT(LIST, func_eval) eval, void *data_eval,
00417                  LIST_CAT(LIST, func_eval) eval_err, void *data_err,
00418                  double *err,
00419                  double *red_chisq)
00420 #ifdef LIST_DEFINE
00421 {
00422     return list_mean_optimal((list *)l,
00423                  (list_func_eval) eval, data_eval,
00424                  (list_func_eval) eval_err, data_err,
00425                  err,
00426                  red_chisq);
00427 }
00428 #else
00429 ;
00430 #endif
00431 
00432 
00433 double
00434 LIST_CAT(LIST, median)(const LIST *l,
00435                LIST_CAT(LIST, func_eval) eval,
00436                void *data)
00437 #ifdef LIST_DEFINE
00438 {
00439     return list_median((const list *)l,
00440                (list_func_eval) eval,
00441                data);
00442 }
00443 #else
00444 ;
00445 #endif
00446 
00447 
00448 double
00449 LIST_CAT(LIST, mad)(LIST *l,
00450             LIST_CAT(LIST, func_eval) eval,
00451             void *data)
00452 #ifdef LIST_DEFINE
00453 {
00454     return list_mad((list *)l,
00455             (list_func_eval) eval,
00456             data);
00457 }
00458 #else
00459 ;
00460 #endif
00461 
00462 CPL_END_DECLS
00463 

Generated on 12 Feb 2016 for FORS Pipeline Reference Manual by  doxygen 1.6.1