Woolz Image Processing Version 1.4.0
HGUDlpList.h
Go to the documentation of this file.
00001 #ifndef HGUDLPLIST_H
00002 #define HGUDLPLIST_H
00003 #if defined(__GNUC__)
00004 #ident "University of Edinburgh $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $"
00005 #else
00006 static char _HGUDlpList_h[] = "University of Edinburgh $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $";
00007 #endif
00008 /*!
00009 * \file         libhguDlpList/HGUDlpList.h
00010 * \author       Bill Hill
00011 * \date         March 1999
00012 * \version      $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $
00013 * \par
00014 * Address:
00015 *               MRC Human Genetics Unit,
00016 *               MRC Institute of Genetics and Molecular Medicine,
00017 *               University of Edinburgh,
00018 *               Western General Hospital,
00019 *               Edinburgh, EH4 2XU, UK.
00020 * \par
00021 * Copyright (C), [2012],
00022 * The University Court of the University of Edinburgh,
00023 * Old College, Edinburgh, UK.
00024 * 
00025 * This program is free software; you can redistribute it and/or
00026 * modify it under the terms of the GNU General Public License
00027 * as published by the Free Software Foundation; either version 2
00028 * of the License, or (at your option) any later version.
00029 *
00030 * This program is distributed in the hope that it will be
00031 * useful but WITHOUT ANY WARRANTY; without even the implied
00032 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00033 * PURPOSE.  See the GNU General Public License for more
00034 * details.
00035 *
00036 * You should have received a copy of the GNU General Public
00037 * License along with this program; if not, write to the Free
00038 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00039 * Boston, MA  02110-1301, USA.
00040 * \brief        Data structures and functions for doubly linked lists
00041 *               linked lists of pointers.
00042 * \ingroup      hguDlpList
00043 */
00044 
00045 #ifndef WLZ_EXT_BIND
00046 #ifdef  __cplusplus
00047 extern "C" {
00048 #endif /* __cplusplus */
00049 #endif /* WLZ_EXT_BIND */
00050 
00051 /*!
00052 * \enum         _HGUDlpListDirection
00053 * \ingroup      hguDlpList
00054 * \brief        List traversal direction;
00055 *               Typedef: ::HGUDlpListDirection
00056 */
00057 typedef enum _HGUDlpListDirection
00058 {
00059   HGU_DLPLIST_DIR_TOHEAD,
00060   HGU_DLPLIST_DIR_TOTAIL
00061 } HGUDlpListDirection;
00062 
00063 /*!
00064  * \enum        _HGUDlpListState
00065  * \ingroup     hguDlpList
00066  * \brief       State of list locking mechanism.
00067  *              Typedef: ::HGUDlpListState
00068  */
00069 typedef enum _HGUDlpListState
00070 {
00071   HGU_DLPLIST_STATE_EMPTY       = (0),
00072   HGU_DLPLIST_STATE_ERROR       = (0),
00073   HGU_DLPLIST_STATE_UNLOCK      = (1),
00074   HGU_DLPLIST_STATE_LOCK        = (1<<1),
00075   HGU_DLPLIST_STATE_CREATE      = (1<<2),
00076   HGU_DLPLIST_STATE_DESTROY     = (1<<3)
00077 } HGUDlpListState;
00078 
00079 #ifdef HGUDLPLIST_C
00080 
00081 typedef struct _HGUDlpListItem                    /* Doubly linked list item */
00082 {
00083   void          (*freeFn)(void *);
00084   void          *entry;
00085   struct _HGUDlpListItem *next;
00086   struct _HGUDlpListItem *prev;
00087 } HGUDlpListItem;
00088  
00089 typedef struct _HGUDlpList                 /* Doubly linked list of pointers */
00090 {
00091   HGUDlpListState (*lockFn)(void *, HGUDlpListState);
00092   void          *lockData;
00093   int           itemCount;
00094   HGUDlpListItem *head;
00095   HGUDlpListItem *tail;
00096  
00097 } HGUDlpList;
00098 
00099 #else /* ! HGUDLPLIST_C */
00100 
00101 /*!
00102  * \typedef     HGUDlpListItem
00103  * \brief       Opaque handle for doubly linked list item.
00104  */
00105 typedef void HGUDlpListItem;
00106 
00107 /*!
00108  * \typedef     HGUDlpList
00109  * \brief       Opaque handle for doubly linked list of pointers.
00110  */
00111 typedef void HGUDlpList;
00112 
00113 extern int                      HGUDlpListSort(
00114                                   HGUDlpList *list,
00115                                   int (*entryCompFn)(void *, void *));
00116 extern int                      HGUDlpListItemIsHead(
00117                                   HGUDlpList *list,
00118                                   HGUDlpListItem *item);
00119 extern int                      HGUDlpListItemIsTail(
00120                                   HGUDlpList *list,
00121                                   HGUDlpListItem *item);
00122 extern int                      HGUDlpListCount(
00123                                   HGUDlpList *list);
00124 extern int                      HGUDlpListOffset(
00125                                   HGUDlpList *list,
00126                                   HGUDlpListItem *item,
00127                                   HGUDlpListDirection dir);
00128 extern void                     HGUDlpListDestroy(
00129                                   HGUDlpList *list);
00130 extern void                     *HGUDlpListEntryGet(
00131                                   HGUDlpList *list,
00132                                   HGUDlpListItem *item);
00133 extern void                     *HGUDlpListEntrySet(
00134                                   HGUDlpList *list,
00135                                   HGUDlpListItem *item,
00136                                   void *entry);
00137 extern HGUDlpList               *HGUDlpListCreate(
00138                                   HGUDlpListState (*lockFn)(void *,
00139                                                             HGUDlpListState)),
00140                                   *HGUDlpListDup(HGUDlpList *list);
00141 extern HGUDlpListItem           *HGUDlpListInsert(HGUDlpList *list,
00142                                         HGUDlpListItem *before, void *entry,
00143                                         void (*freeFn)(void *));
00144 extern HGUDlpListItem           *HGUDlpListAppend(
00145                                   HGUDlpList *list,
00146                                   HGUDlpListItem *after,
00147                                   void *entry,
00148                                   void (*freeFn)(void *));
00149 extern HGUDlpListItem           *HGUDlpListExchange(
00150                                   HGUDlpList *list,
00151                                   HGUDlpListItem *item0,
00152                                   HGUDlpListItem *item1);
00153 extern HGUDlpListItem           *HGUDlpListDeleteAll(
00154                                   HGUDlpList *list);
00155 extern HGUDlpListItem           *HGUDlpListDelete(
00156                                   HGUDlpList *list,
00157                                   HGUDlpListItem *item);
00158 extern HGUDlpListItem           *HGUDlpListRemoveAll(
00159                                   HGUDlpList *list);
00160 extern HGUDlpListItem           *HGUDlpListRemove(
00161                                   HGUDlpList *list,
00162                                   HGUDlpListItem *item);
00163 extern HGUDlpListItem           *HGUDlpListIterate(
00164                                   HGUDlpList *list,
00165                                   HGUDlpListItem *item,
00166                                   HGUDlpListDirection dir,
00167                                   int (*iterFn)(HGUDlpList *, HGUDlpListItem *,
00168                                                 void *),
00169                                   void *iterData);
00170 extern HGUDlpListItem           *HGUDlpListHead(
00171                                   HGUDlpList *list);
00172 extern HGUDlpListItem           *HGUDlpListTail(
00173                                   HGUDlpList *list);
00174 extern HGUDlpListItem           *HGUDlpListNext(
00175                                   HGUDlpList *list, 
00176                                   HGUDlpListItem *item);
00177 extern HGUDlpListItem           *HGUDlpListPrev(
00178                                   HGUDlpList *list,
00179                                   HGUDlpListItem *item);
00180 extern HGUDlpListItem           *HGUDlpListNth(
00181                                   HGUDlpList *list,
00182                                   HGUDlpListItem *item,
00183                                   HGUDlpListDirection dir,
00184                                   int num);
00185 #endif /* HGUDLPLIST_C */
00186 
00187 #ifndef WLZ_EXT_BIND
00188 #ifdef  __cplusplus
00189 }
00190 #endif /* __cplusplus */
00191 #endif /* WLZ_EXT_BIND */
00192 
00193 #endif /* HGUDLPLIST_H */