Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

SUMA_Algorithms.h

Go to the documentation of this file.
00001 /* Code in this file is taken from the book:
00002  "Mastering Algorithms with C"  by Kyle Loudon,  published by O'Reilly & Associates.  This
00003 code is under copyright and cannot be included in any other book, publication,
00004 or  educational product  without  permission  from  O'Reilly & Associates.  No
00005 warranty is attached; we cannot take responsibility for errors or  fitness for
00006 use.
00007 
00008 */
00009 
00010 /**** 
00011    DO NOT INCLUDE SUMA SPECIFIC definitions here 
00012 *****/
00013 
00014 #ifndef SUMA_ALGORITHMS_INCLUDED
00015 #define SUMA_ALGORITHMS_INCLUDED
00016 
00017 /*****************************************************************************
00018 *                                                                            *
00019 *  -------------------------------- list.h --------------------------------  *
00020 *                                                                            *
00021 *****************************************************************************/
00022 
00023 #ifndef LIST_H
00024 #define LIST_H
00025 
00026 
00027 /*****************************************************************************
00028 *                                                                            *
00029 *  Define a structure for linked list elements.                              *
00030 *                                                                            *
00031 *****************************************************************************/
00032 
00033 typedef struct ListElmt_ {
00034 
00035 void               *data;
00036 struct ListElmt_   *next;
00037 
00038 } ListElmt;
00039 
00040 /*****************************************************************************
00041 *                                                                            *
00042 *  Define a structure for linked lists.                                      *
00043 *                                                                            *
00044 *****************************************************************************/
00045 
00046 typedef struct List_ {
00047 
00048 int                size;
00049 
00050 int                (*match)(const void *key1, const void *key2);
00051 void               (*destroy)(void *data);
00052 
00053 ListElmt           *head;
00054 ListElmt           *tail;
00055 
00056 } List;
00057 
00058 /*****************************************************************************
00059 *                                                                            *
00060 *  --------------------------- Public Interface ---------------------------  *
00061 *                                                                            *
00062 *****************************************************************************/
00063 
00064 void list_init(List *list, void (*destroy)(void *data));
00065 
00066 void list_destroy(List *list);
00067 
00068 int list_ins_next(List *list, ListElmt *element, const void *data);
00069 
00070 int list_rem_next(List *list, ListElmt *element, void **data);
00071 
00072 #define list_size(list) ((list)->size)
00073 
00074 #define list_head(list) ((list)->head)
00075 
00076 #define list_tail(list) ((list)->tail)
00077 
00078 #define list_is_head(list, element) ((element) == (list)->head ? 1 : 0)
00079 
00080 #define list_is_tail(element) ((element)->next == NULL ? 1 : 0)
00081 
00082 #define list_data(element) ((element)->data)
00083 
00084 #define list_next(element) ((element)->next)
00085 
00086 #endif
00087 
00088 /*****************************************************************************
00089 *                                                                            *
00090 *  ------------------------------- clist.h --------------------------------  *
00091 *                                                                            *
00092 *****************************************************************************/
00093 
00094 #ifndef CLIST_H
00095 #define CLIST_H
00096 
00097 
00098 /*****************************************************************************
00099 *                                                                            *
00100 *  Define a structure for circular list elements.                            *
00101 *                                                                            *
00102 *****************************************************************************/
00103 
00104 typedef struct CListElmt_ {
00105 
00106 void               *data;
00107 struct CListElmt_  *next;
00108 
00109 } CListElmt;
00110 
00111 /*****************************************************************************
00112 *                                                                            *
00113 *  Define a structure for circular lists.                                    *
00114 *                                                                            *
00115 *****************************************************************************/
00116 
00117 typedef struct CList_ {
00118 
00119 int                size;
00120 
00121 int                (*match)(const void *key1, const void *key2);
00122 void               (*destroy)(void *data);
00123 
00124 CListElmt          *head;
00125 
00126 } CList;
00127 
00128 /*****************************************************************************
00129 *                                                                            *
00130 *  --------------------------- Public Interface ---------------------------  *
00131 *                                                                            *
00132 *****************************************************************************/
00133 
00134 void clist_init(CList *list, void (*destroy)(void *data));
00135 
00136 void clist_destroy(CList *list);
00137 
00138 int clist_ins_next(CList *list, CListElmt *element, const void *data);
00139 
00140 int clist_rem_next(CList *list, CListElmt *element, void **data);
00141 
00142 #define clist_size(list) ((list)->size)
00143 
00144 #define clist_head(list) ((list)->head)
00145 
00146 #define clist_data(element) ((element)->data)
00147 
00148 #define clist_next(element) ((element)->next)
00149 
00150 #endif
00151 
00152 /*****************************************************************************
00153 *                                                                            *
00154 *  ------------------------------- dlist.h --------------------------------  *
00155 *                                                                            *
00156 *****************************************************************************/
00157 
00158 #ifndef DLIST_H
00159 #define DLIST_H
00160 
00161 
00162 /*****************************************************************************
00163 *                                                                            *
00164 *  Define a structure for doubly-linked list elements.                       *
00165 *                                                                            *
00166 *****************************************************************************/
00167 
00168 typedef struct DListElmt_ {
00169 
00170 void               *data;
00171 struct DListElmt_  *prev;
00172 struct DListElmt_  *next;
00173 
00174 } DListElmt;
00175 
00176 /*****************************************************************************
00177 *                                                                            *
00178 *  Define a structure for doubly-linked lists.                               *
00179 *                                                                            *
00180 *****************************************************************************/
00181 
00182 typedef struct DList_ {
00183 
00184 int                size;
00185 
00186 int                (*match)(const void *key1, const void *key2);
00187 void               (*destroy)(void *data);
00188 
00189 DListElmt          *head;
00190 DListElmt          *tail;
00191 
00192 } DList;
00193 
00194 /*****************************************************************************
00195 *                                                                            *
00196 *  --------------------------- Public Interface ---------------------------  *
00197 *                                                                            *
00198 *****************************************************************************/
00199 
00200 void dlist_init(DList *list, void (*destroy)(void *data));
00201 
00202 void dlist_destroy(DList *list);
00203 
00204 int dlist_ins_next(DList *list, DListElmt *element, const void *data);
00205 
00206 int dlist_ins_prev(DList *list, DListElmt *element, const void *data);
00207 
00208 int dlist_remove(DList *list, DListElmt *element, void **data);
00209 
00210 #define dlist_size(list) ((list)->size)
00211 
00212 #define dlist_head(list) ((list)->head)
00213 
00214 #define dlist_tail(list) ((list)->tail)
00215 
00216 #define dlist_is_head(element) ((element)->prev == NULL ? 1 : 0)
00217 
00218 #define dlist_is_tail(element) ((element)->next == NULL ? 1 : 0)
00219 
00220 #define dlist_data(element) ((element)->data)
00221 
00222 #define dlist_next(element) ((element)->next)
00223 
00224 #define dlist_prev(element) ((element)->prev)
00225 
00226 #endif
00227 
00228 
00229 #endif
 

Powered by Plone

This site conforms to the following standards: