ucx/ucx/list.h

Fri, 11 Dec 2020 11:47:30 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 11 Dec 2020 11:47:30 +0100
changeset 168
1b99acacc5bb
parent 162
18892c0a9adc
permissions
-rw-r--r--

refactor widget groups

157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * Doubly linked list implementation.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * @file list.h
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 * @author Mike Becker
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 * @author Olaf Wintermann
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_LIST_H
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_LIST_H
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "ucx.h"
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "allocator.h"
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #ifdef __cplusplus
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 extern "C" {
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #endif
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 * Loop statement for UCX lists.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 * The first argument is the name of the iteration variable. The scope of
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 * this variable is limited to the <code>UCX_FOREACH</code> statement.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 * The second argument is a pointer to the list. In most cases this will be the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 * pointer to the first element of the list, but it may also be an arbitrary
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 * element of the list. The iteration will then start with that element.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 * @param list The first element of the list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 * @param elem The variable name of the element
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 #define UCX_FOREACH(elem,list) \
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
60 for (UcxList* elem = (UcxList*) list ; elem != NULL ; elem = elem->next)
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 * UCX list type.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 * @see UcxList
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 typedef struct UcxList UcxList;
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 * UCX list structure.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 struct UcxList {
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 * List element payload.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 void *data;
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 * Pointer to the next list element or <code>NULL</code>, if this is the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 * last element.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 UcxList *next;
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 * Pointer to the previous list element or <code>NULL</code>, if this is
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 * the first element.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 UcxList *prev;
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 };
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 * Creates an element-wise copy of a list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 * This function clones the specified list by creating new list elements and
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 * copying the data with the specified copy_func(). If no copy_func() is
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 * specified, a shallow copy is created and the new list will reference the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 * same data as the source list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 * @param list the list to copy
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 * @param cpyfnc a pointer to the function that shall copy an element (may be
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 * <code>NULL</code>)
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 * @param data additional data for the copy_func()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 * @return a pointer to the copy
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 */
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
102 UcxList *ucx_list_clone(const UcxList *list, copy_func cpyfnc, void* data);
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 * Creates an element-wise copy of a list using a UcxAllocator.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 * See ucx_list_clone() for details.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 * You might want to pass the allocator via the <code>data</code> parameter,
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 * to access it within the copy function for making deep copies.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 * @param allocator the allocator to use
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 * @param list the list to copy
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 * @param cpyfnc a pointer to the function that shall copy an element (may be
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 * <code>NULL</code>)
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 * @param data additional data for the copy_func()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 * @return a pointer to the copy
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 * @see ucx_list_clone()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 */
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
120 UcxList *ucx_list_clone_a(UcxAllocator *allocator, const UcxList *list,
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 copy_func cpyfnc, void* data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 * Compares two UCX lists element-wise by using a compare function.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 * Each element of the two specified lists are compared by using the specified
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 * compare function and the additional data. The type and content of this
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 * additional data depends on the cmp_func() used.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 * If the list pointers denote elements within a list, the lists are compared
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 * starting with the denoted elements. Thus any previous elements are not taken
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 * into account. This might be useful to check, if certain list tails match
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 * each other.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 * @param list1 the first list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 * @param list2 the second list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 * @param cmpfnc the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 * @param data additional data for the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 * @return 1, if and only if the two lists equal element-wise, 0 otherwise
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 int ucx_list_equals(const UcxList *list1, const UcxList *list2,
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 cmp_func cmpfnc, void* data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 * Destroys the entire list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 * The members of the list are not automatically freed, so ensure they are
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 * otherwise referenced or destroyed by ucx_list_free_contents().
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 * Otherwise, a memory leak is likely to occur.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 * <b>Caution:</b> the argument <b>MUST</b> denote an entire list (i.e. a call
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 * to ucx_list_first() on the argument must return the argument itself)
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 * @param list the list to free
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 * @see ucx_list_free_contents()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 void ucx_list_free(UcxList *list);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 * Destroys the entire list using a UcxAllocator.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 * See ucx_list_free() for details.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 * @param allocator the allocator to use
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 * @param list the list to free
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 * @see ucx_list_free()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 void ucx_list_free_a(UcxAllocator *allocator, UcxList *list);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 * Destroys the contents of the specified list by calling the specified
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 * destructor on each of them.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 * Note, that the contents are not usable afterwards and the list should be
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 * destroyed with ucx_list_free().
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 * If no destructor is specified (<code>NULL</code>), stdlib's free() is used.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 * @param list the list for which the contents shall be freed
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 * @param destr optional destructor function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 * @see ucx_list_free()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 void ucx_list_free_content(UcxList* list, ucx_destructor destr);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 * Inserts an element at the end of the list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 * This is generally an O(n) operation, as the end of the list is retrieved with
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 * ucx_list_last().
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 * @param list the list where to append the data, or <code>NULL</code> to
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 * create a new list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 * @param data the data to insert
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 * the newly created list otherwise
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 UcxList *ucx_list_append(UcxList *list, void *data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 * Inserts an element at the end of the list using a UcxAllocator.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 * See ucx_list_append() for details.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 * @param allocator the allocator to use
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 * @param list the list where to append the data, or <code>NULL</code> to
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 * create a new list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 * @param data the data to insert
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 * @return <code>list</code>, if it is not <code>NULL</code> or a pointer to
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 * the newly created list otherwise
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 * @see ucx_list_append()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 UcxList *ucx_list_append_a(UcxAllocator *allocator, UcxList *list, void *data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 * Inserts an element at the beginning of the list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 * You <i>should</i> overwrite the old list pointer by calling
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 * <code>mylist = ucx_list_prepend(mylist, mydata);</code>. However, you may
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 * also perform successive calls of ucx_list_prepend() on the same list pointer,
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 * as this function always searchs for the head of the list with
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 * ucx_list_first().
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 * @param list the list where to insert the data or <code>NULL</code> to create
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 * a new list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 * @param data the data to insert
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 * @return a pointer to the new list head
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 UcxList *ucx_list_prepend(UcxList *list, void *data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 * Inserts an element at the beginning of the list using a UcxAllocator.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 * See ucx_list_prepend() for details.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 * @param allocator the allocator to use
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 * @param list the list where to insert the data or <code>NULL</code> to create
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 * a new list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 * @param data the data to insert
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 * @return a pointer to the new list head
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 * @see ucx_list_prepend()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 * Concatenates two lists.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 * Either of the two arguments may be <code>NULL</code>.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 * This function modifies the references to the next/previous element of
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 * the last/first element of <code>list1</code>/<code>
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 * list2</code>.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * @param list1 first list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 * @param list2 second list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 * @return if <code>list1</code> is <code>NULL</code>, <code>list2</code> is
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 * returned, otherwise <code>list1</code> is returned
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 * Returns the first element of a list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 * If the argument is the list pointer, it is directly returned. Otherwise
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 * this function traverses to the first element of the list and returns the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 * list pointer.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 * @param elem one element of the list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 * @return the first element of the list, the specified element is a member of
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 UcxList *ucx_list_first(const UcxList *elem);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 * Returns the last element of a list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 * If the argument has no successor, it is the last element and therefore
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 * directly returned. Otherwise this function traverses to the last element of
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 * the list and returns it.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 * @param elem one element of the list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 * @return the last element of the list, the specified element is a member of
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 UcxList *ucx_list_last(const UcxList *elem);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 * Returns the list element at the specified index.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 * @param list the list to retrieve the element from
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 * @param index index of the element to return
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 * @return the element at the specified index or <code>NULL</code>, if the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 * index is greater than the list size
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 UcxList *ucx_list_get(const UcxList *list, size_t index);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 * Returns the index of an element.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 * @param list the list where to search for the element
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 * @param elem the element to find
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 * @return the index of the element or -1 if the list does not contain the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 * element
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 * Returns the element count of the list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 * @param list the list whose elements are counted
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 * @return the element count
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 size_t ucx_list_size(const UcxList *list);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 * Returns the index of an element containing the specified data.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 * This function uses a cmp_func() to compare the data of each list element
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 * with the specified data. If no cmp_func is provided, the pointers are
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 * compared.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 * If the list contains the data more than once, the index of the first
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 * occurrence is returned.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 * @param list the list where to search for the data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 * @param elem the element data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 * @param cmpfnc the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 * @param data additional data for the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 * @return the index of the element containing the specified data or -1 if the
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 * data is not found in this list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 */
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
331 ssize_t ucx_list_find(const UcxList *list, void *elem,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
332 cmp_func cmpfnc, void *data);
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 * Checks, if a list contains a specific element.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 * An element is found, if ucx_list_find() returns a value greater than -1.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 * @param list the list where to search for the data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 * @param elem the element data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 * @param cmpfnc the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 * @param data additional data for the compare function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 * @return 1, if and only if the list contains the specified element data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 * @see ucx_list_find()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 */
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
346 int ucx_list_contains(const UcxList *list, void *elem,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
347 cmp_func cmpfnc, void *data);
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 * Sorts a UcxList with natural merge sort.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352 * This function uses O(n) additional temporary memory for merge operations
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 * that is automatically freed after each merge.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 * As the head of the list might change, you <b>MUST</b> call this function
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 * as follows: <code>mylist = ucx_list_sort(mylist, mycmpfnc, mydata);</code>.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 * @param list the list to sort
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 * @param cmpfnc the function that shall be used to compare the element data
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 * @param data additional data for the cmp_func()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 * @return the sorted list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 UcxList *ucx_list_sort(UcxList *list, cmp_func cmpfnc, void *data);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 * Removes an element from the list.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 * If the first element is removed, the list pointer changes. So it is
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 * <i>highly recommended</i> to <i>always</i> update the pointer by calling
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 * <code>mylist = ucx_list_remove(mylist, myelem);</code>.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 * @param list the list from which the element shall be removed
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 * @param element the element to remove
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 * @return returns the updated list pointer or <code>NULL</code>, if the list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 * is now empty
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 UcxList *ucx_list_remove(UcxList *list, UcxList *element);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 /**
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 * Removes an element from the list using a UcxAllocator.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 * See ucx_list_remove() for details.
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 *
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 * @param allocator the allocator to use
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 * @param list the list from which the element shall be removed
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 * @param element the element to remove
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 * @return returns the updated list pointer or <code>NULL</code>, if the list
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 * @see ucx_list_remove()
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 UcxList *ucx_list_remove_a(UcxAllocator *allocator, UcxList *list,
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 UcxList *element);
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
393 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
394 * Returns the union of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
395 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
396 * The union is a list of unique elements regarding cmpfnc obtained from
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
397 * both source lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
398 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
399 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
400 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
401 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
402 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
403 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
404 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
405 * @return a new list containing the union
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
406 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
407 UcxList* ucx_list_union(const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
408 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
409 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
410
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
411 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
412 * Returns the union of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
413 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
414 * The union is a list of unique elements regarding cmpfnc obtained from
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
415 * both source lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
416 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
417 * @param allocator allocates the new list elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
418 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
419 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
420 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
421 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
422 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
423 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
424 * @return a new list containing the union
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
425 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
426 UcxList* ucx_list_union_a(UcxAllocator *allocator,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
427 const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
428 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
429 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
430
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
431 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
432 * Returns the intersection of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
433 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
434 * The intersection contains all elements of the left list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
435 * (including duplicates) that can be found in the right list.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
436 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
437 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
438 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
439 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
440 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
441 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
442 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
443 * @return a new list containing the intersection
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
444 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
445 UcxList* ucx_list_intersection(const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
446 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
447 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
448
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
449 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
450 * Returns the intersection of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
451 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
452 * The intersection contains all elements of the left list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
453 * (including duplicates) that can be found in the right list.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
454 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
455 * @param allocator allocates the new list elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
456 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
457 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
458 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
459 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
460 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
461 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
462 * @return a new list containing the intersection
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
463 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
464 UcxList* ucx_list_intersection_a(UcxAllocator *allocator,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
465 const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
466 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
467 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
468
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
469 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
470 * Returns the difference of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
471 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
472 * The difference contains all elements of the left list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
473 * (including duplicates) that are not equal to any element of the right list.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
474 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
475 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
476 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
477 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
478 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
479 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
480 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
481 * @return a new list containing the difference
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
482 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
483 UcxList* ucx_list_difference(const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
484 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
485 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
486
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
487 /**
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
488 * Returns the difference of two lists.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
489 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
490 * The difference contains all elements of the left list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
491 * (including duplicates) that are not equal to any element of the right list.
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
492 *
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
493 * @param allocator allocates the new list elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
494 * @param left the left source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
495 * @param right the right source list
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
496 * @param cmpfnc a function to compare elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
497 * @param cmpdata additional data for the compare function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
498 * @param cpfnc a function to copy the elements
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
499 * @param cpdata additional data for the copy function
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
500 * @return a new list containing the difference
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
501 */
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
502 UcxList* ucx_list_difference_a(UcxAllocator *allocator,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
503 const UcxList *left, const UcxList *right,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
504 cmp_func cmpfnc, void* cmpdata,
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
505 copy_func cpfnc, void* cpdata);
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 157
diff changeset
506
157
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 #ifdef __cplusplus
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 }
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 #endif
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 #endif /* UCX_LIST_H */
0b33b9396851 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512

mercurial