ucx/list.h

Mon, 21 Jul 2014 13:04:57 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 21 Jul 2014 13:04:57 +0200
changeset 183
6a694f8f0084
parent 177
11ad03783baf
child 192
1e51558b9d09
permissions
-rw-r--r--

added sstrcat documentation

103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
1 /*
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
3 *
177
11ad03783baf go ahead, nothing to see here
Mike Becker <universe@uap-core.de>
parents: 172
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
5 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
6 * Redistribution and use in source and binary forms, with or without
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
7 * modification, are permitted provided that the following conditions are met:
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
8 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
10 * notice, this list of conditions and the following disclaimer.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
11 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
14 * documentation and/or other materials provided with the distribution.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
15 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
28 /**
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
29 * Doubly linked list implementation.
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
30 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
31 * @file list.h
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
32 * @author Mike Becker
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
33 * @author Olaf Wintermann
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
34 */
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
36 #ifndef UCX_LIST_H
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
37 #define UCX_LIST_H
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38
7
68091406d1cf added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents: 4
diff changeset
39 #include "ucx.h"
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
40 #include "allocator.h"
7
68091406d1cf added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents: 4
diff changeset
41
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 #ifdef __cplusplus
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 extern "C" {
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 #endif
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
121
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
46 /**
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
47 * Loop statement for UCX lists.
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
48 *
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
49 * The first argument is a pointer to the list. In most cases this will be the
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
50 * pointer to the first element of the list, but it may also be an arbitrary
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
51 * element of the list. The iteration will then start with that element.
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
52 *
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
53 * The second argument is the name of the iteration variable. The scope of
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
54 * this variable is limited to the <code>UCX_FOREACH</code> statement.
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
55 *
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
56 * @param list The first element of the list
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
57 * @param elem The variable name of the element
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
58 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
59 #define UCX_FOREACH(elem,list) \
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
60 for (UcxList* elem = list ; elem != NULL ; elem = elem->next)
121
311cac04d079 removal of single linked list implemenation - step 1: removal
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
61
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
62 /**
129
61edec666928 documentation for UcxLogger
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
63 * UCX list type.
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
64 * @see UcxList
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
65 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
66 typedef struct UcxList UcxList;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
67
129
61edec666928 documentation for UcxLogger
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
68 /**
61edec666928 documentation for UcxLogger
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
69 * UCX list structure.
61edec666928 documentation for UcxLogger
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
70 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
71 struct UcxList {
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
72 /**
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
73 * List element payload.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
74 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
75 void *data;
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
76 /**
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
77 * Pointer to the next list element or <code>NULL</code>, if this is the
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
78 * last element.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
79 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
80 UcxList *next;
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
81 /**
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
82 * Pointer to the previous list element or <code>NULL</code>, if this is
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
83 * the first element.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
84 */
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
85 UcxList *prev;
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 };
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
88 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
89 * Creates an element-wise copy of a list.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
90 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
91 * This function clones the specified list by creating new list elements and
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
92 * copying the data with the specified copy_func(). If no copy_func() is
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
93 * specified, a shallow copy is created and the new list will reference the
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
94 * same data as the source list.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
95 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
96 * @param list the list to copy
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
97 * @param cpyfnc a pointer to the function that shall copy an element (may be
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
98 * <code>NULL</code>)
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
99 * @param data additional data for the copy_func()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
100 * @return a pointer to the copy
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
101 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
102 UcxList *ucx_list_clone(UcxList *list, copy_func cpyfnc, void* data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
103
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
104 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
105 * Creates an element-wise copy of a list using an UcxAllocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
106 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
107 * See ucx_list_clone() for details.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
108 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
109 * Keep in mind, that you might want to pass the allocator as an (part of the)
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
110 * argument for the <code>data</code> parameter, if you want the copy_func() to
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
111 * make use of the allocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
112 *
129
61edec666928 documentation for UcxLogger
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
113 * @param allocator the allocator to use
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
114 * @param list the list to copy
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
115 * @param cpyfnc a pointer to the function that shall copy an element (may be
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
116 * <code>NULL</code>)
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
117 * @param data additional data for the copy_func()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
118 * @return a pointer to the copy
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
119 * @see ucx_list_clone()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
120 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
121 UcxList *ucx_list_clone_a(UcxAllocator *allocator, UcxList *list,
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
122 copy_func cpyfnc, void* data);
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
124 /**
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
125 * Compares two UCX lists element-wise by using a compare function.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
126 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
127 * Each element of the two specified lists are compared by using the specified
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
128 * compare function and the additional data. The type and content of this
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
129 * additional data depends on the cmp_func() used.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
130 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
131 * If the list pointers denote elements within a list, the lists are compared
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
132 * starting with the denoted elements. Thus any previous elements are not taken
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
133 * into account. This might be useful to check, if certain list tails match
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
134 * each other.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
135 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
136 * @param list1 the first list
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
137 * @param list2 the second list
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
138 * @param cmpfnc the compare function
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
139 * @param data additional data for the compare function
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
140 * @return 1, if and only if the two lists equal element-wise, 0 otherwise
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
141 */
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
142 int ucx_list_equals(const UcxList *list1, const UcxList *list2,
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
143 cmp_func cmpfnc, void* data);
18
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 8
diff changeset
144
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
145 /**
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
146 * Destroys the entire list.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
147 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
148 * The members of the list are not automatically freed, so ensure they are
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
149 * otherwise referenced or a memory leak will occur.
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
150 *
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
151 * <b>Caution:</b> the argument <b>MUST</b> denote an entire list (i.e. a call
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
152 * to ucx_list_first() on the argument must return the argument itself)
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
153 *
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
154 * @param list the list to free
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
155 */
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
156 void ucx_list_free(UcxList *list);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
157
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
158 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
159 * Destroys the entire list using an UcxAllocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
160 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
161 * See ucx_list_free() for details.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
162 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
163 * @param allocator the allocator to use
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
164 * @param list the list to free
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
165 * @see ucx_list_free()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
166 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
167 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
168
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
169 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
170 * Inserts an element at the end of the list.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
171 *
172
7084e8e8433c refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
172 * This is generally an O(n) operation, as the end of the list is retrieved with
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
173 * ucx_list_last().
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
174 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
175 * @param list the list where to append the data, or <code>NULL</code> to
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
176 * create a new list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
177 * @param data the data to insert
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
178 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
179 * the newly created list otherwise
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
180 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
181 UcxList *ucx_list_append(UcxList *list, void *data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
182
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
183 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
184 * Inserts an element at the end of the list using an UcxAllocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
185 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
186 * See ucx_list_append() for details.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
187 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
188 * @param allocator the allocator to use
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
189 * @param list the list where to append the data, or <code>NULL</code> to
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
190 * create a new list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
191 * @param data the data to insert
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
192 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
193 * the newly created list otherwise
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
194 * @see ucx_list_append()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
195 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
196 UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
197
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
198 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
199 * Inserts an element at the beginning of the list.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
200 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
201 * You <i>should</i> overwrite the old list pointer by calling
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
202 * <code>mylist = ucx_list_prepend(mylist, mydata);</code>. However, you may
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
203 * also perform successive calls of ucx_list_prepend() on the same list pointer,
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
204 * as this function always searchs for the head of the list with
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
205 * ucx_list_first().
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
206 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
207 * @param list the list where to insert the data or <code>NULL</code> to create
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
208 * a new list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
209 * @param data the data to insert
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
210 * @return a pointer to the new list head
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
211 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
212 UcxList *ucx_list_prepend(UcxList *list, void *data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
213
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
214 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
215 * Inserts an element at the beginning of the list using an UcxAllocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
216 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
217 * See ucx_list_prepend() for details.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
218 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
219 * @param allocator the allocator to use
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
220 * @param list the list where to insert the data or <code>NULL</code> to create
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
221 * a new list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
222 * @param data the data to insert
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
223 * @return a pointer to the new list head
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
224 * @see ucx_list_prepend()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
225 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
226 UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
227
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
228 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
229 * Concatenates two lists.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
230 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
231 * Either of the two arguments may be <code>NULL</code>.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
232 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
233 * This function modifies the references to the next/previous element of
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
234 * the last/first element of <code>list1</code>/<code>
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
235 * list2</code>.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
236 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
237 * @param list1 first list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
238 * @param list2 second list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
239 * @return if <code>list1</code> is <code>NULL</code>, <code>list2</code> is
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
240 * returned, otherwise <code>list1</code> is returned
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
241 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
242 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
243
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
244 /**
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
245 * Returns the first element of a list.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
246 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
247 * If the argument is the list pointer, it is directly returned. Otherwise
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
248 * this function traverses to the first element of the list and returns the
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
249 * list pointer.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
250 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
251 * @param elem one element of the list
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
252 * @return the first element of the list, the specified element is a member of
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
253 */
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
254 UcxList *ucx_list_first(const UcxList *elem);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
255
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
256 /**
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
257 * Returns the last element of a list.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
258 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
259 * If the argument has no successor, it is the last element and therefore
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
260 * directly returned. Otherwise this function traverses to the last element of
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
261 * the list and returns it.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
262 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
263 * @param elem one element of the list
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
264 * @return the last element of the list, the specified element is a member of
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
265 */
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
266 UcxList *ucx_list_last(const UcxList *elem);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
267
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
268 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
269 * Returns the list element at the specified index.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
270 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
271 * @param list the list to retrieve the element from
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
272 * @param index index of the element to return
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
273 * @return the element at the specified index or <code>NULL</code>, if the
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
274 * index is greater than the list size
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
275 */
172
7084e8e8433c refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
276 UcxList *ucx_list_get(const UcxList *list, size_t index);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
277
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
278 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
279 * Returns the index of an element.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
280 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
281 * @param list the list where to search for the element
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
282 * @param elem the element to find
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
283 * @return the index of the element or -1 if the list does not contain the
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
284 * element
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
285 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
286 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
287
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
288 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
289 * Returns the element count of the list.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
290 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
291 * @param list the list whose elements are counted
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
292 * @return the element count
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
293 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
294 size_t ucx_list_size(const UcxList *list);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
295
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
296 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
297 * Returns the index of an element containing the specified data.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
298 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
299 * This function uses a cmp_func() to compare the data of each list element
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
300 * with the specified data. If no cmp_func is provided, the pointers are
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
301 * compared.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
302 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
303 * If the list contains the data more than once, the index of the first
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
304 * occurrence is returned.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
305 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
306 * @param list the list where to search for the data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
307 * @param elem the element data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
308 * @param cmpfnc the compare function
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
309 * @param data additional data for the compare function
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
310 * @return the index of the element containing the specified data or -1 if the
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
311 * data is not found in this list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
312 */
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
313 ssize_t ucx_list_find(UcxList *list, void *elem, cmp_func cmpfnc, void *data);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
314
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
315 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
316 * Checks, if a list contains a specific element.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
317 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
318 * An element is found, if ucx_list_find() returns a value greater than -1.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
319 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
320 * @param list the list where to search for the data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
321 * @param elem the element data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
322 * @param cmpfnc the compare function
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
323 * @param data additional data for the compare function
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
324 * @return 1, if and only if the list contains the specified element data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
325 * @see ucx_list_find()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
326 */
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
327 int ucx_list_contains(UcxList *list, void *elem, cmp_func cmpfnc, void *data);
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
328
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
329 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
330 * Sorts an UcxList with natural merge sort.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
331 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
332 * This function uses O(n) additional temporary memory for merge operations
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
333 * that is automatically freed after each merge.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
334 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
335 * As the head of the list might change, you <b>MUST</b> call this function
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
336 * as follows: <code>mylist = ucx_list_sort(mylist, mycmpfnc, mydata);</code>.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
337 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
338 * @param list the list to sort
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
339 * @param cmpfnc the function that shall be used to compare the element data
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
340 * @param data additional data for the cmp_func()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
341 * @return the sorted list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
342 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
343 UcxList *ucx_list_sort(UcxList *list, cmp_func cmpfnc, void *data);
35
fdabd1240b69 added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents: 27
diff changeset
344
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
345 /**
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
346 * Removes an element from the list.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
347 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
348 * If the first element is removed, the list pointer changes. So it is
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
349 * <i>highly recommended</i> to <i>always</i> update the pointer by calling
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
350 * <code>mylist = ucx_list_remove(mylist, myelem);</code>.
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
351 *
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
352 * @param list the list from which the element shall be removed
172
7084e8e8433c refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
353 * @param element the element to remove
124
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
354 * @return returns the updated list pointer or <code>NULL</code>, if the list
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
355 * is now empty
8b44653541ef more documentation for UcxList
Mike Becker <universe@uap-core.de>
parents: 123
diff changeset
356 */
123
7fb0f74517c5 changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents: 122
diff changeset
357 UcxList *ucx_list_remove(UcxList *list, UcxList *element);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
358
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
359 /**
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
360 * Removes an element from the list using an UcxAllocator.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
361 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
362 * See ucx_list_remove() for details.
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
363 *
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
364 * @param allocator the allocator to use
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
365 * @param list the list from which the element shall be removed
172
7084e8e8433c refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents: 146
diff changeset
366 * @param element the element to remove
128
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
367 * @return returns the updated list pointer or <code>NULL</code>, if the list
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
368 * @see ucx_list_remove()
b79b1ce438dd finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
369 */
125
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
370 UcxList *ucx_list_remove_a(UcxAllocator *allocator, UcxList *list,
fca8efb122de changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents: 124
diff changeset
371 UcxList *element);
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
372
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
373 #ifdef __cplusplus
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
374 }
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
375 #endif
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
376
122
540d99722f1f removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
377 #endif /* UCX_LIST_H */
4
dbc31727b38e added dlist specification
Mike Becker <universe@uap-core.de>
parents:
diff changeset
378

mercurial