ptrlist.h

Thu, 03 Aug 2006 23:09:14 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 03 Aug 2006 23:09:14 +0200
changeset 102
c00694dbcde8
parent 101
50525dab6c8e
child 111
7d1dccdd7215
permissions
-rw-r--r--

Updated locations of *.mk.

60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
1 /*
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
2 * libtu/ptrlist.h
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
3 *
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2005.
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
5 *
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
6 * You may distribute and modify this library under the terms of either
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
8 */
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
9
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
10 #ifndef LIBTU_PTRLIST_H
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
11 #define LIBTU_PTRLIST_H
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
12
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
13 #include "types.h"
94
f48ffd2f2224 Added routinesn for generic iterables.
Tuomo Valkonen <tuomov@iki.fi>
parents: 93
diff changeset
14 #include "iterable.h"
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
15
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
16
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
17 INTRSTRUCT(PtrList);
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
18
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
19
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
20 DECLSTRUCT(PtrList){
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
21 void *ptr;
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
22 PtrList *next, *prev;
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
23 };
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
24
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
25
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
26 typedef PtrList* PtrListIterTmp;
88
308dfa54da3e Symlist improvements.
Tuomo Valkonen <tuomov@iki.fi>
parents: 62
diff changeset
27
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
28 #define PTRLIST_FIRST(TYPE, LL) ((LL)==NULL ? NULL : (TYPE)(LL)->ptr)
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
29 #define PTRLIST_LAST(TYPE, LL) ((LL)==NULL ? NULL : (TYPE)(LL)->prev->ptr)
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
30 #define PTRLIST_EMPTY(LIST) ((LIST)==NULL)
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
31
93
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
32 #define FOR_ALL_ON_PTRLIST(TYPE, VAR, LL, TMP) \
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
33 FOR_ALL_ITER(ptrlist_iter_init, (TYPE)ptrlist_iter, VAR, LL, &(TMP))
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
34
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
35 #define FOR_ALL_ON_PTRLIST_REV(TYPE, VAR, LL, TMP) \
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
36 FOR_ALL_ITER(ptrlist_iter_rev_init, \
5f72042eb91c Increased FOR_ALL macro reuse.
Tuomo Valkonen <tuomov@iki.fi>
parents: 92
diff changeset
37 (TYPE)ptrlist_iter_rev, VAR, LL, &(TMP))
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
38
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
39 #define FOR_ALL_ON_PTRLIST_UNSAFE(TYPE, VAR, LL) \
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
40 FOR_ALL_ON_PTRLIST(TYPE, VAR, LL, ptrlist_iter_tmp)
88
308dfa54da3e Symlist improvements.
Tuomo Valkonen <tuomov@iki.fi>
parents: 62
diff changeset
41
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
42 extern PtrListIterTmp ptrlist_iter_tmp;
88
308dfa54da3e Symlist improvements.
Tuomo Valkonen <tuomov@iki.fi>
parents: 62
diff changeset
43
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
44 extern bool ptrlist_insert_last(PtrList **ptrlist, void *ptr);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
45 extern bool ptrlist_insert_first(PtrList **ptrlist, void *ptr);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
46 extern bool ptrlist_reinsert_last(PtrList **ptrlist, void *ptr);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
47 extern bool ptrlist_reinsert_first(PtrList **ptrlist, void *ptr);
101
50525dab6c8e *list_remove return true if the item was found (and removed).
Tuomo Valkonen <tuomov@iki.fi>
parents: 94
diff changeset
48 extern bool ptrlist_remove(PtrList **ptrlist, void *ptr);
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
49 extern void ptrlist_clear(PtrList **ptrlist);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
50 extern void ptrlist_iter_init(PtrListIterTmp *state, PtrList *ptrlist);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
51 extern void *ptrlist_iter(PtrListIterTmp *state);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
52 extern void ptrlist_iter_rev_init(PtrListIterTmp *state, PtrList *ptrlist);
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
53 extern void *ptrlist_iter_rev(PtrListIterTmp *state);
92
55fcdff5bcea Added routines to take first/last elements of objlist and ptrlist.
Tuomo Valkonen <tuomov@iki.fi>
parents: 90
diff changeset
54 extern void *ptrlist_take_first(PtrList **ptrlist);
55fcdff5bcea Added routines to take first/last elements of objlist and ptrlist.
Tuomo Valkonen <tuomov@iki.fi>
parents: 90
diff changeset
55 extern void *ptrlist_take_last(PtrList **ptrlist);
60
a4033700e35c trunk: changeset 1313
tuomov
parents:
diff changeset
56
90
f5a392131875 Renamed Symlist PtrList.
Tuomo Valkonen <tuomov@iki.fi>
parents: 88
diff changeset
57 #endif /* LIBTU_PTRLIST_H */

mercurial