ucx/cx/list.h

Sun, 09 Jun 2024 15:31:07 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 09 Jun 2024 15:31:07 +0200
branch
newapi
changeset 283
bb0b8927f5c0
parent 253
087cc9216f28
child 324
ce13a778654a
permissions
-rw-r--r--

add dnd selection functions (unimplemented) (GTK)

174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0358f1d9c506 upgrade ucx
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
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * \file list.h
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 * \brief Interface for list implementations.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * \author Mike Becker
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 * \author Olaf Wintermann
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 * \copyright 2-Clause BSD License
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_LIST_H
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_LIST_H
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "common.h"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "collection.h"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #ifdef __cplusplus
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 extern "C" {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #endif
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 * List class type.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 typedef struct cx_list_class_s cx_list_class;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 * Structure for holding the base data of a list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 struct cx_list_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 CX_COLLECTION_MEMBERS
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 * The list class definition.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 cx_list_class const *cl;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 * The actual implementation in case the list class is delegating.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 cx_list_class const *climpl;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 * The class definition for arbitrary lists.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 struct cx_list_class_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 * Destructor function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 * Implementations SHALL invoke the content destructor functions if provided
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 * and SHALL deallocate the list memory, if an allocator is provided.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 void (*destructor)(struct cx_list_s *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 /**
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
79 * Member function for inserting a single element.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 * Implementors SHOULD see to performant implementations for corner cases.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 int (*insert_element)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 struct cx_list_s *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 size_t index,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 void const *data
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 * Member function for inserting multiple elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 * Implementors SHOULD see to performant implementations for corner cases.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 size_t (*insert_array)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 struct cx_list_s *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 size_t index,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 void const *data,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 size_t n
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 * Member function for inserting an element relative to an iterator position.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 int (*insert_iter)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 struct cx_mut_iterator_s *iter,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 void const *elem,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 int prepend
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 * Member function for removing an element.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 int (*remove)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 struct cx_list_s *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 * Member function for removing all elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 void (*clear)(struct cx_list_s *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 * Member function for swapping two elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 int (*swap)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 struct cx_list_s *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 size_t i,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 size_t j
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 * Member function for element lookup.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 void *(*at)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 struct cx_list_s const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 /**
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
139 * Member function for finding and optionally removing an element.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 */
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
141 ssize_t (*find_remove)(
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
142 struct cx_list_s *list,
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
143 void const *elem,
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
144 bool remove
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 /**
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
148 * Member function for sorting the list in-place.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 void (*sort)(struct cx_list_s *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 * Member function for comparing this list to another list of the same type.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 int (*compare)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 struct cx_list_s const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 struct cx_list_s const *other
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 * Member function for reversing the order of the items.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 void (*reverse)(struct cx_list_s *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 * Member function for returning an iterator pointing to the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 struct cx_iterator_s (*iterator)(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 struct cx_list_s const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 size_t index,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 bool backward
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 * Common type for all list implementations.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 typedef struct cx_list_s CxList;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 * Advises the list to store copies of the objects (default mode of operation).
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 * Retrieving objects from this list will yield pointers to the copies stored
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 * within this list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 * @see cxListStorePointers()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 void cxListStoreObjects(CxList *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 * Advises the list to only store pointers to the objects.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 * Retrieving objects from this list will yield the original pointers stored.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 * @note This function forcibly sets the element size to the size of a pointer.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 * Invoking this function on a non-empty list that already stores copies of
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 * objects is undefined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 * @see cxListStoreObjects()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 void cxListStorePointers(CxList *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 * Returns true, if this list is storing pointers instead of the actual data.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 * @param list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 * @return true, if this list is storing pointers
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 * @see cxListStorePointers()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 static inline bool cxListIsStoringPointers(CxList const *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 return list->store_pointer;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 * Returns the number of elements currently stored in the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 * @return the number of currently stored elements
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 static inline size_t cxListSize(CxList const *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 return list->size;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 * Adds an item to the end of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 * @param elem a pointer to the element to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 * @return zero on success, non-zero on memory allocation failure
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 * @see cxListAddArray()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 static inline int cxListAdd(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 void const *elem
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 return list->cl->insert_element(list, list->size, elem);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 * Adds multiple items to the end of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 * This method is more efficient than invoking cxListAdd() multiple times.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 * If there is not enough memory to add all elements, the returned value is
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 * less than \p n.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 * If this list is storing pointers instead of objects \p array is expected to
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * be an array of pointers.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 * @param array a pointer to the elements to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 * @param n the number of elements to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 * @return the number of added elements
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 static inline size_t cxListAddArray(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 void const *array,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 size_t n
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 return list->cl->insert_array(list, list->size, array, n);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 * Inserts an item at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 * If \p index equals the list \c size, this is effectively cxListAdd().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 * @param index the index the element shall have
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 * @param elem a pointer to the element to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 * @return zero on success, non-zero on memory allocation failure
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 * or when the index is out of bounds
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 * @see cxListInsertAfter()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 * @see cxListInsertBefore()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 static inline int cxListInsert(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 size_t index,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 void const *elem
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 return list->cl->insert_element(list, index, elem);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 * Inserts multiple items to the list at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 * If \p index equals the list size, this is effectively cxListAddArray().
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 * This method is usually more efficient than invoking cxListInsert()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 * multiple times.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 * If there is not enough memory to add all elements, the returned value is
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 * less than \p n.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 * If this list is storing pointers instead of objects \p array is expected to
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 * be an array of pointers.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 * @param index the index where to add the elements
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 * @param array a pointer to the elements to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 * @param n the number of elements to add
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 * @return the number of added elements
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 static inline size_t cxListInsertArray(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 size_t index,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 void const *array,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 size_t n
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 return list->cl->insert_array(list, index, array, n);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 * Inserts an element after the current location of the specified iterator.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 * The used iterator remains operational, but all other active iterators should
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 * be considered invalidated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 * If \p iter is not a list iterator, the behavior is undefined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 * If \p iter is a past-the-end iterator, the new element gets appended to the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 * @param iter an iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 * @param elem the element to insert
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 * @return zero on success, non-zero on memory allocation failure
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 * @see cxListInsert()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 * @see cxListInsertBefore()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 static inline int cxListInsertAfter(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 CxMutIterator *iter,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 void const *elem
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 * Inserts an element before the current location of the specified iterator.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 * The used iterator remains operational, but all other active iterators should
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 * be considered invalidated.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 * If \p iter is not a list iterator, the behavior is undefined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352 * If \p iter is a past-the-end iterator, the new element gets appended to the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 * @param iter an iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 * @param elem the element to insert
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 * @return zero on success, non-zero on memory allocation failure
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 * @see cxListInsert()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 * @see cxListInsertAfter()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 static inline int cxListInsertBefore(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 CxMutIterator *iter,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 void const *elem
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 * Removes the element at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 * If an element destructor function is specified, it is called before
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 * removing the element.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 * @param index the index of the element
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 * @return zero on success, non-zero if the index is out of bounds
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 static inline int cxListRemove(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 return list->cl->remove(list, index);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 * Removes all elements from this list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 * If an element destructor function is specified, it is called for each
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 * element before removing them.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 static inline void cxListClear(CxList *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 list->cl->clear(list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 * Swaps two items in the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 * Implementations should only allocate temporary memory for the swap, if
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 * it is necessary.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 * @param i the index of the first element
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 * @param j the index of the second element
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 * @return zero on success, non-zero if one of the indices is out of bounds
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 static inline int cxListSwap(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 size_t i,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 size_t j
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 return list->cl->swap(list, i, j);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 * Returns a pointer to the element at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 * @param index the index of the element
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 * @return a pointer to the element or \c NULL if the index is out of bounds
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 static inline void *cxListAt(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 return list->cl->at(list, index);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 * Returns an iterator pointing to the item at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 * If the index is out of range, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 * @param index the index where the iterator shall point at
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 static inline CxIterator cxListIteratorAt(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 CxList const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 return list->cl->iterator(list, index, false);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 * Returns a backwards iterator pointing to the item at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 * If the index is out of range, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 * @param index the index where the iterator shall point at
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 static inline CxIterator cxListBackwardsIteratorAt(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 CxList const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 ) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 return list->cl->iterator(list, index, true);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 * Returns a mutating iterator pointing to the item at the specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 * If the index is out of range, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 * @param index the index where the iterator shall point at
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 CxMutIterator cxListMutIteratorAt(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 * Returns a mutating backwards iterator pointing to the item at the
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 * specified index.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 * If the index is out of range, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498 * @param index the index where the iterator shall point at
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
500 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 CxMutIterator cxListMutBackwardsIteratorAt(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 CxList *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 size_t index
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 * Returns an iterator pointing to the first item of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 * If the list is empty, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 static inline CxIterator cxListIterator(CxList const *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 return list->cl->iterator(list, 0, false);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
523 * Returns a mutating iterator pointing to the first item of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
524 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 * If the list is empty, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
529 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
530 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533 static inline CxMutIterator cxListMutIterator(CxList *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534 return cxListMutIteratorAt(list, 0);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
535 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539 * Returns a backwards iterator pointing to the last item of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
541 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 * If the list is empty, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
546 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
548 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
549 static inline CxIterator cxListBackwardsIterator(CxList const *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550 return list->cl->iterator(list, list->size - 1, true);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
551 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 * Returns a mutating backwards iterator pointing to the last item of the list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 * The returned iterator is position-aware.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 * If the list is empty, a past-the-end iterator will be returned.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561 * @return a new iterator
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 __attribute__((__nonnull__, __warn_unused_result__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 static inline CxMutIterator cxListMutBackwardsIterator(CxList *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 return cxListMutBackwardsIteratorAt(list, list->size - 1);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569 * Returns the index of the first element that equals \p elem.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 * Determining equality is performed by the list's comparator function.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 * @param elem the element to find
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 * @return the index of the element or a negative
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576 * value when the element is not found
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 static inline ssize_t cxListFind(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580 CxList const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 void const *elem
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582 ) {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
583 return list->cl->find_remove((CxList*)list, elem, false);
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
584 }
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
585
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
586 /**
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
587 * Removes and returns the index of the first element that equals \p elem.
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
588 *
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
589 * Determining equality is performed by the list's comparator function.
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
590 *
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
591 * @param list the list
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
592 * @param elem the element to find and remove
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
593 * @return the index of the now removed element or a negative
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
594 * value when the element is not found or could not be removed
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
595 */
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
596 __attribute__((__nonnull__))
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
597 static inline ssize_t cxListFindRemove(
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
598 CxList *list,
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
599 void const *elem
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
600 ) {
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
601 return list->cl->find_remove(list, elem, true);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 /**
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
605 * Sorts the list in-place.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607 * \remark The underlying sort algorithm is implementation defined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
610 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 static inline void cxListSort(CxList *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 list->cl->sort(list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
614 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
615
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 * Reverses the order of the items.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
619 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
620 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 static inline void cxListReverse(CxList *list) {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 list->cl->reverse(list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
624 }
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
625
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
626 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627 * Compares a list to another list of the same type.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
628 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 * First, the list sizes are compared.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
630 * If they match, the lists are compared element-wise.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
631 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
632 * @param list the list
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 * @param other the list to compare to
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 * @return zero, if both lists are equal element wise,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 * negative if the first list is smaller, positive if the first list is larger
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 int cxListCompare(
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 CxList const *list,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 CxList const *other
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 );
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
644 * Deallocates the memory of the specified list structure.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
645 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
646 * Also calls content a destructor function, depending on the configuration
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
647 * in CxList.content_destructor_type.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
648 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
649 * This function itself is a destructor function for the CxList.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
650 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
651 * @param list the list which shall be destroyed
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
652 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
653 __attribute__((__nonnull__))
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
654 void cxListDestroy(CxList *list);
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
655
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
656 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
657 * A shared instance of an empty list.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
658 *
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
659 * Writing to that list is undefined.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
660 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
661 extern CxList * const cxEmptyList;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
662
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
663
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
664 #ifdef __cplusplus
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
665 } // extern "C"
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
666 #endif
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
667
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
668 #endif // UCX_LIST_H

mercurial