Woolz Image Processing  Version 1.8.3
HGUDlpList.h
Go to the documentation of this file.
1 #ifndef HGUDLPLIST_H
2 #define HGUDLPLIST_H
3 #if defined(__GNUC__)
4 #ident "University of Edinburgh $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $"
5 #else
6 static char _HGUDlpList_h[] = "University of Edinburgh $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $";
7 #endif
8 /*!
9 * \file libhguDlpList/HGUDlpList.h
10 * \author Bill Hill
11 * \date March 1999
12 * \version $Id: 3ef0e2c8562fa955c61e9e757fc9e672c10da307 $
13 * \par
14 * Address:
15 * MRC Human Genetics Unit,
16 * MRC Institute of Genetics and Molecular Medicine,
17 * University of Edinburgh,
18 * Western General Hospital,
19 * Edinburgh, EH4 2XU, UK.
20 * \par
21 * Copyright (C), [2012],
22 * The University Court of the University of Edinburgh,
23 * Old College, Edinburgh, UK.
24 *
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation; either version 2
28 * of the License, or (at your option) any later version.
29 *
30 * This program is distributed in the hope that it will be
31 * useful but WITHOUT ANY WARRANTY; without even the implied
32 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
33 * PURPOSE. See the GNU General Public License for more
34 * details.
35 *
36 * You should have received a copy of the GNU General Public
37 * License along with this program; if not, write to the Free
38 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
39 * Boston, MA 02110-1301, USA.
40 * \brief Data structures and functions for doubly linked lists
41 * linked lists of pointers.
42 * \ingroup hguDlpList
43 */
44 
45 #ifndef WLZ_EXT_BIND
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 #endif /* WLZ_EXT_BIND */
50 
51 /*!
52 * \enum _HGUDlpListDirection
53 * \ingroup hguDlpList
54 * \brief List traversal direction;
55 * Typedef: ::HGUDlpListDirection
56 */
58 {
62 
63 /*!
64  * \enum _HGUDlpListState
65  * \ingroup hguDlpList
66  * \brief State of list locking mechanism.
67  * Typedef: ::HGUDlpListState
68  */
69 typedef enum _HGUDlpListState
70 {
78 
79 #ifdef HGUDLPLIST_C
80 
81 typedef struct _HGUDlpListItem /* Doubly linked list item */
82 {
83  void (*freeFn)(void *);
84  void *entry;
85  struct _HGUDlpListItem *next;
86  struct _HGUDlpListItem *prev;
88 
89 typedef struct _HGUDlpList /* Doubly linked list of pointers */
90 {
91  HGUDlpListState (*lockFn)(void *, HGUDlpListState);
92  void *lockData;
93  int itemCount;
94  HGUDlpListItem *head;
95  HGUDlpListItem *tail;
96 
97 } HGUDlpList;
98 
99 #else /* ! HGUDLPLIST_C */
100 
101 /*!
102  * \typedef HGUDlpListItem
103  * \brief Opaque handle for doubly linked list item.
104  */
105 typedef void HGUDlpListItem;
106 
107 /*!
108  * \typedef HGUDlpList
109  * \brief Opaque handle for doubly linked list of pointers.
110  */
111 typedef void HGUDlpList;
112 
113 extern int HGUDlpListSort(
114  HGUDlpList *list,
115  int (*entryCompFn)(void *, void *));
116 extern int HGUDlpListItemIsHead(
117  HGUDlpList *list,
118  HGUDlpListItem *item);
119 extern int HGUDlpListItemIsTail(
120  HGUDlpList *list,
121  HGUDlpListItem *item);
122 extern int HGUDlpListCount(
123  HGUDlpList *list);
124 extern int HGUDlpListOffset(
125  HGUDlpList *list,
126  HGUDlpListItem *item,
127  HGUDlpListDirection dir);
128 extern void HGUDlpListDestroy(
129  HGUDlpList *list);
130 extern void *HGUDlpListEntryGet(
131  HGUDlpList *list,
132  HGUDlpListItem *item);
133 extern void *HGUDlpListEntrySet(
134  HGUDlpList *list,
135  HGUDlpListItem *item,
136  void *entry);
138  HGUDlpListState (*lockFn)(void *,
139  HGUDlpListState)),
140  *HGUDlpListDup(HGUDlpList *list);
142  HGUDlpListItem *before, void *entry,
143  void (*freeFn)(void *));
145  HGUDlpList *list,
146  HGUDlpListItem *after,
147  void *entry,
148  void (*freeFn)(void *));
150  HGUDlpList *list,
151  HGUDlpListItem *item0,
152  HGUDlpListItem *item1);
154  HGUDlpList *list);
156  HGUDlpList *list,
157  HGUDlpListItem *item);
159  HGUDlpList *list);
161  HGUDlpList *list,
162  HGUDlpListItem *item);
164  HGUDlpList *list,
165  HGUDlpListItem *item,
167  int (*iterFn)(HGUDlpList *, HGUDlpListItem *,
168  void *),
169  void *iterData);
171  HGUDlpList *list);
173  HGUDlpList *list);
175  HGUDlpList *list,
176  HGUDlpListItem *item);
178  HGUDlpList *list,
179  HGUDlpListItem *item);
181  HGUDlpList *list,
182  HGUDlpListItem *item,
184  int num);
185 #endif /* HGUDLPLIST_C */
186 
187 #ifndef WLZ_EXT_BIND
188 #ifdef __cplusplus
189 }
190 #endif /* __cplusplus */
191 #endif /* WLZ_EXT_BIND */
192 
193 #endif /* HGUDLPLIST_H */
void * HGUDlpListEntrySet(HGUDlpList *list, HGUDlpListItem *item, void *entry)
Sets the given items entry and returns the previous entry. Entries are NEVER freed by this function...
Definition: HGUDlpList.c:713
HGUDlpListItem * HGUDlpListInsert(HGUDlpList *list, HGUDlpListItem *before, void *entry, void(*freeFn)(void *))
Inserts the given entry into the list before the given item.
Definition: HGUDlpList.c:160
enum _HGUDlpListDirection HGUDlpListDirection
void HGUDlpListItem
Opaque handle for doubly linked list item.
Definition: HGUDlpList.h:105
_HGUDlpListDirection
List traversal direction; Typedef: HGUDlpListDirection.
Definition: HGUDlpList.h:57
HGUDlpListItem * HGUDlpListRemoveAll(HGUDlpList *list)
Definition: HGUDlpList.h:75
HGUDlpListItem * HGUDlpListAppend(HGUDlpList *list, HGUDlpListItem *after, void *entry, void(*freeFn)(void *))
Appends the given entry into the list after the given item.
Definition: HGUDlpList.c:230
Definition: HGUDlpList.h:73
void HGUDlpList
Opaque handle for doubly linked list of pointers.
Definition: HGUDlpList.h:111
int HGUDlpListItemIsTail(HGUDlpList *list, HGUDlpListItem *item)
Looks to see if the given item is at the tail of the given list.
Definition: HGUDlpList.c:666
Definition: HGUDlpList.h:74
HGUDlpListItem * HGUDlpListExchange(HGUDlpList *list, HGUDlpListItem *item0, HGUDlpListItem *item1)
Exchanges the two given list item entries and not the items, so that head is still head and tail is s...
Definition: HGUDlpList.c:298
Definition: HGUDlpList.h:60
Definition: HGUDlpList.h:59
HGUDlpListItem * HGUDlpListPrev(HGUDlpList *list, HGUDlpListItem *item)
Returns the prev list item.
Definition: HGUDlpList.c:789
enum _HGUDlpListState HGUDlpListState
HGUDlpListItem * HGUDlpListDeleteAll(HGUDlpList *list)
Deletes all list items from the head on down to and including the tail. Where delete implies both the...
Definition: HGUDlpList.c:330
int HGUDlpListOffset(HGUDlpList *list, HGUDlpListItem *item, HGUDlpListDirection dir)
Counts the number of items from the given item to the item with a NULL next/prev item, which is at the head or tail of list. The offset between an item and itself is defined to be zero.
Definition: HGUDlpList.c:603
int HGUDlpListItemIsHead(HGUDlpList *list, HGUDlpListItem *item)
Looks to see if the given item is at the head of the given list.
Definition: HGUDlpList.c:638
HGUDlpListItem * HGUDlpListTail(HGUDlpList *list)
Returns the tail list item.
Definition: HGUDlpList.c:737
int HGUDlpListCount(HGUDlpList *list)
Returns the number of items in the list.
Definition: HGUDlpList.c:805
_HGUDlpListState
State of list locking mechanism. Typedef: HGUDlpListState.
Definition: HGUDlpList.h:69
HGUDlpListItem * HGUDlpListHead(HGUDlpList *list)
Returns the head list item.
Definition: HGUDlpList.c:753
HGUDlpListItem * HGUDlpListDelete(HGUDlpList *list, HGUDlpListItem *item)
Deletes the given list item from the list with the given list. Where delete implies both the removal ...
Definition: HGUDlpList.c:354
int HGUDlpListSort(HGUDlpList *list, int(*entryCompFn)(void *, void *))
Sorts the entire list using the given entry comparison function.
Definition: HGUDlpList.c:398
HGUDlpList * HGUDlpListDup(HGUDlpList *list)
Duplicates a list data structure, but NOT its items. Ie head and tail are both NULL and the item coun...
Definition: HGUDlpList.c:116
Definition: HGUDlpList.h:71
HGUDlpListItem * HGUDlpListNth(HGUDlpList *list, HGUDlpListItem *item, HGUDlpListDirection dir, int num)
Finds the n'th item from the given item in the list. The n'th item from the head or tail can be found...
Definition: HGUDlpList.c:516
HGUDlpListItem * HGUDlpListIterate(HGUDlpList *list, HGUDlpListItem *item, HGUDlpListDirection dir, int(*iterFn)(HGUDlpList *, HGUDlpListItem *, void *), void *iterData)
Iterates the given function through the list, starting with the supplied given item. The iteration may proceed toward either the head or tail of the list. The iterated function must take the form of:
Definition: HGUDlpList.c:460
HGUDlpListItem * HGUDlpListNext(HGUDlpList *list, HGUDlpListItem *item)
Returns the next list item.
Definition: HGUDlpList.c:771
void HGUDlpListDestroy(HGUDlpList *list)
Destroys the given list list data structure and any list items.
Definition: HGUDlpList.c:132
Definition: HGUDlpList.h:72
void * HGUDlpListEntryGet(HGUDlpList *list, HGUDlpListItem *item)
Returns the list items entry.
Definition: HGUDlpList.c:693
HGUDlpList * HGUDlpListCreate(HGUDlpListState(*lockFn)(void *, HGUDlpListState))
Definition: HGUDlpList.h:76
HGUDlpListItem * HGUDlpListRemove(HGUDlpList *list, HGUDlpListItem *item)
Removes the item from the list withe the given list. Where remove implies the removal of the item fro...
Definition: HGUDlpList.c:374