Sat, 27 Dec 2025 22:47:56 +0100
update toolkit, ucx
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
2483f517c562
add existing toolkit code
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 |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
29 | * @file list.h |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
30 | * @brief Interface for list implementations. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
31 | * @author Mike Becker |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
32 | * @author Olaf Wintermann |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
33 | * @copyright 2-Clause BSD License |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #ifndef UCX_LIST_H |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #define UCX_LIST_H |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | #include "common.h" |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | #include "collection.h" |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | #ifdef __cplusplus |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | extern "C" { |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | #endif |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | * List class type. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | typedef struct cx_list_class_s cx_list_class; |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | * Structure for holding the base data of a list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | struct cx_list_s { |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
55 | /** |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
56 | * Common members for collections. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
57 | */ |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
58 | CX_COLLECTION_BASE; |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | * The list class definition. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | */ |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
62 | const cx_list_class *cl; |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | }; |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | * The class definition for arbitrary lists. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | struct cx_list_class_s { |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | * Destructor function. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | * Implementations SHALL invoke the content destructor functions if provided |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
73 | * and SHALL deallocate the entire list memory. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
75 | void (*deallocate)(struct cx_list_s *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | * Member function for inserting a single element. |
| 112 | 79 | * The data pointer may be @c NULL, in which case the function shall only allocate memory. |
| 80 | * Returns a pointer to the allocated memory or @c NULL if allocation fails. | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | */ |
| 113 | 82 | void *(*insert_element)(struct cx_list_s *list, size_t index, const void *data); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | * Member function for inserting multiple elements. |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
86 | * |
| 113 | 87 | * The data pointer may be @c NULL, in which case the function shall only allocate memory. |
| 88 | * Returns the number of successfully inserted or allocated elements. | |
| 89 | * | |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
90 | * @see cx_list_default_insert_array() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | */ |
| 113 | 92 | size_t (*insert_array)(struct cx_list_s *list, size_t index, const void *data, size_t n); |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
93 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
94 | /** |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
95 | * Member function for inserting sorted elements into a sorted list. |
| 113 | 96 | * Returns the number of successfully inserted elements. |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
97 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
98 | * @see cx_list_default_insert_sorted() |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
99 | */ |
| 113 | 100 | size_t (*insert_sorted)(struct cx_list_s *list, const void *sorted_data, size_t n); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | /** |
| 112 | 103 | * Member function for inserting multiple elements if they do not exist. |
| 113 | 104 | * Implementations shall return the number of successfully processed elements |
| 105 | * (including those which were not added because they are already contained). | |
| 112 | 106 | * @see cx_list_default_insert_unique() |
| 107 | */ | |
| 113 | 108 | size_t (*insert_unique)(struct cx_list_s *list, const void *sorted_data, size_t n); |
| 112 | 109 | |
| 110 | /** | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | * Member function for inserting an element relative to an iterator position. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | */ |
| 113 | 113 | int (*insert_iter)(struct cx_iterator_s *iter, const void *elem, int prepend); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
116 | * Member function for removing elements. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
117 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
118 | * Implementations SHALL check if @p targetbuf is set and copy the elements |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
119 | * to the buffer without invoking any destructor. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
120 | * When @p targetbuf is not set, the destructors SHALL be invoked. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
121 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
122 | * The function SHALL return the actual number of elements removed, which |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
123 | * might be lower than @p num when going out of bounds. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | */ |
| 113 | 125 | size_t (*remove)(struct cx_list_s *list, size_t index, size_t num, void *targetbuf); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | * Member function for removing all elements. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | void (*clear)(struct cx_list_s *list); |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | * Member function for swapping two elements. |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
134 | * |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
135 | * @see cx_list_default_swap() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | */ |
| 113 | 137 | int (*swap)(struct cx_list_s *list, size_t i, size_t j); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | * Member function for element lookup. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | */ |
| 113 | 142 | void *(*at)(const struct cx_list_s *list, size_t index); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | /** |
|
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
145 | * Member function for finding and optionally removing an element. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | */ |
| 113 | 147 | size_t (*find_remove)(struct cx_list_s *list, const void *elem, bool remove); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
150 | * Member function for sorting the list. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
151 | * |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
152 | * @see cx_list_default_sort() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | void (*sort)(struct cx_list_s *list); |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | /** |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
157 | * Optional member function for comparing this list |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
158 | * to another list of the same type. |
| 112 | 159 | * If set to @c NULL, the comparison won't be optimized. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | */ |
| 113 | 161 | int (*compare)(const struct cx_list_s *list, const struct cx_list_s *other); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | * Member function for reversing the order of the items. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | */ |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | void (*reverse)(struct cx_list_s *list); |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | /** |
| 113 | 169 | * Optional member function for changing the capacity. |
| 170 | * If the list does not support overallocation, this can be set to @c NULL. | |
| 171 | */ | |
| 172 | int (*change_capacity)(struct cx_list_s *list, size_t new_capacity); | |
| 173 | ||
| 174 | /** | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | * Member function for returning an iterator pointing to the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | */ |
| 113 | 177 | struct cx_iterator_s (*iterator)(const struct cx_list_s *list, size_t index, bool backward); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | }; |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | /** |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
181 | * Common type for all list implementations. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
182 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
183 | typedef struct cx_list_s CxList; |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
184 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
185 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
186 | * A shared instance of an empty list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
187 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
188 | * Writing to that list is not allowed. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
189 | * |
| 112 | 190 | * You can use this as a placeholder for initializing CxList pointers |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
191 | * for which you do not want to reserve memory right from the beginning. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
192 | */ |
| 113 | 193 | CX_EXPORT extern CxList *const cxEmptyList; |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
194 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
195 | /** |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
196 | * Default implementation of an array insert. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
197 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
198 | * This function uses the element insert function for each element of the array. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
199 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
200 | * Use this in your own list class if you do not want to implement an optimized |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
201 | * version for your list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
202 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
203 | * @param list the list |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
204 | * @param index the index where to insert the data |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
205 | * @param data a pointer to the array of data to insert |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
206 | * @param n the number of elements to insert |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
207 | * @return the number of elements actually inserted |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
208 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
209 | cx_attr_nonnull |
| 113 | 210 | CX_EXPORT size_t cx_list_default_insert_array(struct cx_list_s *list, |
| 211 | size_t index, const void *data, size_t n); | |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
212 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
213 | /** |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
214 | * Default implementation of a sorted insert. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
215 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
216 | * This function uses the array insert function to insert consecutive groups |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
217 | * of sorted data. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
218 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
219 | * The source data @em must already be sorted wrt. the list's compare function. |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
220 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
221 | * Use this in your own list class if you do not want to implement an optimized |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
222 | * version for your list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
223 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
224 | * @param list the list |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
225 | * @param sorted_data a pointer to the array of pre-sorted data to insert |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
226 | * @param n the number of elements to insert |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
227 | * @return the number of elements actually inserted |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
228 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
229 | cx_attr_nonnull |
| 113 | 230 | CX_EXPORT size_t cx_list_default_insert_sorted(struct cx_list_s *list, |
| 231 | const void *sorted_data, size_t n); | |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
232 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
233 | /** |
| 112 | 234 | * Default implementation of an array insert where only elements are inserted when they don't exist in the list. |
| 235 | * | |
| 236 | * This function is similar to cx_list_default_insert_sorted(), except it skips elements that are already in the list. | |
| 237 | * | |
| 238 | * @note The return value of this function denotes the number of elements from the @p sorted_data that are definitely | |
| 239 | * contained in the list after completing the call. It is @em not the number of elements that were newly inserted. | |
| 240 | * That means, when no error occurred, the return value should be @p n. | |
| 241 | * | |
| 242 | * Use this in your own list class if you do not want to implement an optimized version for your list. | |
| 243 | * | |
| 244 | * @param list the list | |
| 245 | * @param sorted_data a pointer to the array of pre-sorted data to insert | |
| 246 | * @param n the number of elements to insert | |
| 247 | * @return the number of elements from the @p sorted_data that are definitely present in the list after this call | |
| 248 | */ | |
| 249 | cx_attr_nonnull | |
| 113 | 250 | CX_EXPORT size_t cx_list_default_insert_unique(struct cx_list_s *list, |
| 251 | const void *sorted_data, size_t n); | |
| 112 | 252 | |
| 253 | /** | |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
254 | * Default unoptimized sort implementation. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
255 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
256 | * This function will copy all data to an array, sort the array with standard |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
257 | * qsort, and then copy the data back to the list memory. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
258 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
259 | * Use this in your own list class if you do not want to implement an optimized |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
260 | * version for your list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
261 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
262 | * @param list the list that shall be sorted |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
263 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
264 | cx_attr_nonnull |
| 113 | 265 | CX_EXPORT void cx_list_default_sort(struct cx_list_s *list); |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
266 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
267 | /** |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
268 | * Default unoptimized swap implementation. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
269 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
270 | * Use this in your own list class if you do not want to implement an optimized |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
271 | * version for your list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
272 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
273 | * @param list the list in which to swap |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
274 | * @param i index of one element |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
275 | * @param j index of the other element |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
276 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
277 | * @retval non-zero when indices are out of bounds or memory |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
278 | * allocation for the temporary buffer fails |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
279 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
280 | cx_attr_nonnull |
| 113 | 281 | CX_EXPORT int cx_list_default_swap(struct cx_list_s *list, size_t i, size_t j); |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
282 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
283 | /** |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
284 | * Initializes a list struct. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
285 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
286 | * Only use this function if you are creating your own list implementation. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
287 | * The purpose of this function is to be called in the initialization code |
| 112 | 288 | * of your list to set certain members correctly. |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
289 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
290 | * This is particularly important when you want your list to support |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
291 | * #CX_STORE_POINTERS as @p elem_size. This function will wrap the list |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
292 | * class accordingly and make sure that you can implement your list as if |
| 112 | 293 | * it was only storing objects, and the wrapper will automatically enable |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
294 | * the feature of storing pointers. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
295 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
296 | * @par Example |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
297 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
298 | * @code |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
299 | * CxList *myCustomListCreate( |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
300 | * const CxAllocator *allocator, |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
301 | * size_t elem_size |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
302 | * ) { |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
303 | * if (allocator == NULL) { |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
304 | * allocator = cxDefaultAllocator; |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
305 | * } |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
306 | * |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
307 | * MyCustomList *list = cxZalloc(allocator, sizeof(MyCustomList)); |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
308 | * if (list == NULL) return NULL; |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
309 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
310 | * // initialize |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
311 | * cx_list_init((CxList*)list, &my_custom_list_class, |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
312 | * allocator, elem_size); |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
313 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
314 | * // ... some more custom stuff ... |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
315 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
316 | * return (CxList *) list; |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
317 | * } |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
318 | * @endcode |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
319 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
320 | * @param list the list to initialize |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
321 | * @param cl the list class |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
322 | * @param allocator the allocator for the elements |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
323 | * @param elem_size the size of one element |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
324 | */ |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
325 | cx_attr_nonnull_arg(1, 2, 3) |
| 113 | 326 | CX_EXPORT void cx_list_init(struct cx_list_s *list, |
| 327 | struct cx_list_class_s *cl, const struct cx_allocator_s *allocator, | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
328 | size_t elem_size); |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
329 | |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
330 | /** |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
331 | * A @c cx_compare_func2 compatible wrapper for the compare functions of a list. |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
332 | * |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
333 | * @param left first element |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
334 | * @param right second element |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
335 | * @param list the list which is comparing the elements |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
336 | * @return the comparison result |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
337 | */ |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
338 | cx_attr_nonnull |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
339 | CX_EXPORT int cx_list_compare_wrapper( |
|
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
340 | const void *left, const void *right, void *list); |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
341 | |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
342 | /** |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
343 | * Returns the number of elements currently stored in the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
344 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | * @return the number of currently stored elements |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
348 | cx_attr_nonnull |
| 113 | 349 | CX_EXPORT size_t cxListSize(const CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
351 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | * Adds an item to the end of the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | * @param elem a pointer to the element to add |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
356 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
357 | * @retval non-zero memory allocation failure |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | * @see cxListAddArray() |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
359 | * @see cxListEmplace() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
361 | cx_attr_nonnull |
| 113 | 362 | CX_EXPORT int cxListAdd(CxList *list, const void *elem); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
363 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
364 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
365 | * Adds multiple items to the end of the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
366 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
367 | * This method is more efficient than invoking cxListAdd() multiple times. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
368 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
369 | * If there is not enough memory to add all elements, the returned value is |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
370 | * less than @p n. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
371 | * |
| 112 | 372 | * If this list is storing pointers instead of objects, @p array is expected to |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
373 | * be an array of pointers. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
374 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
375 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
376 | * @param array a pointer to the elements to add |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
377 | * @param n the number of elements to add |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
378 | * @return the number of added elements |
| 113 | 379 | * @see cxListEmplaceArray() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
380 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
381 | cx_attr_nonnull |
| 113 | 382 | CX_EXPORT size_t cxListAddArray(CxList *list, const void *array, size_t n); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
383 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
384 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
385 | * Inserts an item at the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
386 | * |
| 112 | 387 | * If the @p index equals the list @c size, this is effectively cxListAdd(). |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
388 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
389 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
390 | * @param index the index the element shall have |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
391 | * @param elem a pointer to the element to add |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
392 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
393 | * @retval non-zero memory allocation failure or the index is out of bounds |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
394 | * @see cxListInsertAfter() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
395 | * @see cxListInsertBefore() |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
396 | * @see cxListEmplaceAt() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
397 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
398 | cx_attr_nonnull |
| 113 | 399 | CX_EXPORT int cxListInsert(CxList *list, size_t index, const void *elem); |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
400 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
401 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
402 | * Allocates memory for an element at the specified index and returns a pointer to that memory. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
403 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
404 | * @remark When the list is storing pointers, this will return a @c void**. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
405 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
406 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
407 | * @param index the index where to emplace the element |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
408 | * @return a pointer to the allocated memory; @c NULL when the operation fails, or the index is out-of-bounds |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
409 | * @see cxListEmplace() |
| 113 | 410 | * @see cxListEmplaceArrayAt() |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
411 | * @see cxListInsert() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
412 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
413 | cx_attr_nonnull |
| 113 | 414 | CX_EXPORT void *cxListEmplaceAt(CxList *list, size_t index); |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
415 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
416 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
417 | * Allocates memory for an element at the end of the list and returns a pointer to that memory. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
418 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
419 | * @remark When the list is storing pointers, this will return a @c void**. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
420 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
421 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
422 | * @return a pointer to the allocated memory; @c NULL when the operation fails, or the index is out-of-bounds |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
423 | * @see cxListEmplaceAt() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
424 | * @see cxListAdd() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
425 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
426 | cx_attr_nonnull |
| 113 | 427 | CX_EXPORT void *cxListEmplace(CxList *list); |
| 428 | ||
| 429 | /** | |
| 430 | * Allocates memory for multiple elements and returns an iterator. | |
| 431 | * | |
| 432 | * The iterator will only iterate over the successfully allocated elements. | |
| 433 | * The @c elem_count attribute is set to that number, and the @c index attribute | |
| 434 | * will range from zero to @c elem_count minus one. | |
| 435 | * | |
| 436 | * @remark When the list is storing pointers, the iterator will iterate over | |
| 437 | * the @c void** elements. | |
| 438 | * | |
| 439 | * @param list the list | |
| 440 | * @param index the index where to insert the new data | |
| 441 | * @param n the number of elements for which to allocate the memory | |
| 442 | * @return an iterator, iterating over the new memory | |
| 443 | * @see cxListEmplaceAt() | |
| 444 | * @see cxListInsertArray() | |
| 445 | */ | |
| 446 | cx_attr_nonnull | |
| 447 | CX_EXPORT CxIterator cxListEmplaceArrayAt(CxList *list, size_t index, size_t n); | |
| 448 | ||
| 449 | /** | |
| 450 | * Allocates memory for multiple elements and returns an iterator. | |
| 451 | * | |
| 452 | * The iterator will only iterate over the successfully allocated elements. | |
| 453 | * The @c elem_count attribute is set to that number, and the @c index attribute | |
| 454 | * will range from zero to @c elem_count minus one. | |
| 455 | * | |
| 456 | * @remark When the list is storing pointers, the iterator will iterate over | |
| 457 | * the @c void** elements. | |
| 458 | * | |
| 459 | * @param list the list | |
| 460 | * @param n the number of elements for which to allocate the memory | |
| 461 | * @return an iterator, iterating over the new memory | |
| 462 | * @see cxListEmplace() | |
| 463 | * @see cxListAddArray() | |
| 464 | */ | |
| 465 | cx_attr_nonnull | |
| 466 | CX_EXPORT CxIterator cxListEmplaceArray(CxList *list, size_t n); | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
467 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
468 | /** |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
469 | * Inserts an item into a sorted list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
470 | * |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
471 | * If the list is not sorted already, the behavior is undefined. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
472 | * |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
473 | * @param list the list |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
474 | * @param elem a pointer to the element to add |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
475 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
476 | * @retval non-zero memory allocation failure |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
477 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
478 | cx_attr_nonnull |
| 113 | 479 | CX_EXPORT int cxListInsertSorted(CxList *list, const void *elem); |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
480 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
481 | /** |
| 113 | 482 | * Inserts an item into a list if it does not exist. |
| 112 | 483 | * |
| 113 | 484 | * If the list is not sorted already, this function will check all elements |
| 485 | * and append the new element when it was not found. | |
| 486 | * It is strongly recommended to use this function only on sorted lists, where | |
| 487 | * the element, if it is not contained, is inserted at the correct position. | |
| 112 | 488 | * |
| 489 | * @param list the list | |
| 490 | * @param elem a pointer to the element to add | |
| 491 | * @retval zero success (also when the element was already in the list) | |
| 492 | * @retval non-zero memory allocation failure | |
| 493 | */ | |
| 494 | cx_attr_nonnull | |
| 113 | 495 | CX_EXPORT int cxListInsertUnique(CxList *list, const void *elem); |
| 112 | 496 | |
| 497 | /** | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
498 | * Inserts multiple items to the list at the specified index. |
| 112 | 499 | * If the @p index equals the list size, this is effectively cxListAddArray(). |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
500 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
501 | * This method is usually more efficient than invoking cxListInsert() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
502 | * multiple times. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
503 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
504 | * If there is not enough memory to add all elements, the returned value is |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
505 | * less than @p n. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
506 | * |
| 112 | 507 | * If this list is storing pointers instead of objects, @p array is expected to |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
508 | * be an array of pointers. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
509 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
510 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
511 | * @param index the index where to add the elements |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
512 | * @param array a pointer to the elements to add |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
513 | * @param n the number of elements to add |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
514 | * @return the number of added elements |
| 113 | 515 | * @see cxListEmplaceArrayAt() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
516 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
517 | cx_attr_nonnull |
| 113 | 518 | CX_EXPORT size_t cxListInsertArray(CxList *list, size_t index, const void *array, size_t n); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
519 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
520 | /** |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
521 | * Inserts a sorted array into a sorted list. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
522 | * |
| 112 | 523 | * This method is usually more efficient than inserting each element separately |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
524 | * because consecutive chunks of sorted data are inserted in one pass. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
525 | * |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
526 | * If there is not enough memory to add all elements, the returned value is |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
527 | * less than @p n. |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
528 | * |
| 112 | 529 | * If this list is storing pointers instead of objects, @p array is expected to |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
530 | * be an array of pointers. |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
531 | * |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
532 | * If the list is not sorted already, the behavior is undefined. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
533 | * |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
534 | * @param list the list |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
535 | * @param array a pointer to the elements to add |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
536 | * @param n the number of elements to add |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
537 | * @return the number of added elements |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
538 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
539 | cx_attr_nonnull |
| 113 | 540 | CX_EXPORT size_t cxListInsertSortedArray(CxList *list, const void *array, size_t n); |
|
49
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
541 | |
|
2f71f4ee247a
update toolkit, ucx, libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
2
diff
changeset
|
542 | /** |
| 113 | 543 | * Inserts an array into a list, skipping duplicates. |
| 544 | * | |
| 545 | * The @p list does not need to be sorted (in contrast to cxListInsertSortedArray()). | |
| 546 | * But it is strongly recommended to use this function only on sorted lists, | |
| 547 | * because otherwise it will fall back to an inefficient algorithm which inserts | |
| 548 | * all elements one by one. | |
| 549 | * If the @p list is not sorted, the @p array also does not need to be sorted. | |
| 550 | * But when the @p list is sorted, the @p array must also be sorted. | |
| 112 | 551 | * |
| 552 | * This method is usually more efficient than inserting each element separately | |
| 553 | * because consecutive chunks of sorted data are inserted in one pass. | |
| 554 | * | |
| 555 | * If there is not enough memory to add all elements, the returned value is | |
| 556 | * less than @p n. | |
| 557 | * | |
| 558 | * @note The return value of this function denotes the number of elements | |
| 559 | * from the @p sorted_data that are definitely contained in the list after | |
| 560 | * completing the call. It is @em not the number of elements that were newly | |
| 561 | * inserted. That means, when no error occurred, the return value should | |
| 562 | * be @p n. | |
| 563 | * | |
| 564 | * If this list is storing pointers instead of objects @p array is expected to | |
| 565 | * be an array of pointers. | |
| 566 | * | |
| 567 | * @param list the list | |
| 568 | * @param array a pointer to the elements to add | |
| 569 | * @param n the number of elements to add | |
| 570 | * @return the number of added elements | |
| 571 | * | |
| 572 | * @return the number of elements from the @p sorted_data that are definitely present in the list after this call | |
| 573 | */ | |
| 574 | cx_attr_nonnull | |
| 113 | 575 | CX_EXPORT size_t cxListInsertUniqueArray(CxList *list, const void *array, size_t n); |
| 112 | 576 | |
| 577 | /** | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
578 | * Inserts an element after the current location of the specified iterator. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
579 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
580 | * The used iterator remains operational, but all other active iterators should |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
581 | * be considered invalidated. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
582 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
583 | * If @p iter is not a list iterator, the behavior is undefined. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
584 | * If @p iter is a past-the-end iterator, the new element gets appended to the list. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
585 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
586 | * @param iter an iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
587 | * @param elem the element to insert |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
588 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
589 | * @retval non-zero memory allocation failure |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
590 | * @see cxListInsert() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
591 | * @see cxListInsertBefore() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
592 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
593 | cx_attr_nonnull |
| 113 | 594 | CX_EXPORT int cxListInsertAfter(CxIterator *iter, const void *elem); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
595 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
596 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
597 | * Inserts an element before the current location of the specified iterator. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
598 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
599 | * The used iterator remains operational, but all other active iterators should |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
600 | * be considered invalidated. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
601 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
602 | * If @p iter is not a list iterator, the behavior is undefined. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
603 | * If @p iter is a past-the-end iterator, the new element gets appended to the list. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
604 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
605 | * @param iter an iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
606 | * @param elem the element to insert |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
607 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
608 | * @retval non-zero memory allocation failure |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
609 | * @see cxListInsert() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
610 | * @see cxListInsertAfter() |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
611 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
612 | cx_attr_nonnull |
| 113 | 613 | CX_EXPORT int cxListInsertBefore(CxIterator *iter, const void *elem); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
614 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
615 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
616 | * Removes the element at the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
617 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
618 | * If an element destructor function is specified, it is called before |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
619 | * removing the element. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
620 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
621 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
622 | * @param index the index of the element |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
623 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
624 | * @retval non-zero index out of bounds |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
625 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
626 | cx_attr_nonnull |
| 113 | 627 | CX_EXPORT int cxListRemove(CxList *list, size_t index); |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
628 | |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
629 | /** |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
630 | * Removes and returns the element at the specified index. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
631 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
632 | * No destructor is called, and instead the element is copied to the |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
633 | * @p targetbuf which MUST be large enough to hold the removed element. |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
634 | * If the list is storing pointers, only the pointer is copied to @p targetbuf. |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
635 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
636 | * @param list the list |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
637 | * @param index the index of the element |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
638 | * @param targetbuf a buffer where to copy the element |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
639 | * @retval zero success |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
640 | * @retval non-zero index out of bounds |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
641 | */ |
| 113 | 642 | cx_attr_nonnull cx_attr_access_w(3) |
| 643 | CX_EXPORT int cxListRemoveAndGet(CxList *list, size_t index, void *targetbuf); | |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
644 | |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
645 | /** |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
646 | * Removes and returns the first element of the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
647 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
648 | * No destructor is called, and instead the element is copied to the |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
649 | * @p targetbuf which MUST be large enough to hold the removed element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
650 | * If the list is storing pointers, only the pointer is copied to @p targetbuf. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
651 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
652 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
653 | * @param targetbuf a buffer where to copy the element |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
654 | * @retval zero success |
| 112 | 655 | * @retval non-zero the list is empty |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
656 | * @see cxListPopFront() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
657 | * @see cxListRemoveAndGetLast() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
658 | */ |
| 113 | 659 | cx_attr_nonnull cx_attr_access_w(2) |
| 660 | CX_EXPORT int cxListRemoveAndGetFirst(CxList *list, void *targetbuf); | |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
661 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
662 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
663 | * Removes and returns the first element of the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
664 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
665 | * Alias for cxListRemoveAndGetFirst(). |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
666 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
667 | * No destructor is called, and instead the element is copied to the |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
668 | * @p targetbuf which MUST be large enough to hold the removed element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
669 | * If the list is storing pointers, only the pointer is copied to @p targetbuf. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
670 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
671 | * @param list (@c CxList*) the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
672 | * @param targetbuf (@c void*) a buffer where to copy the element |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
673 | * @retval zero success |
| 112 | 674 | * @retval non-zero the list is empty |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
675 | * @see cxListRemoveAndGetFirst() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
676 | * @see cxListPop() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
677 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
678 | #define cxListPopFront(list, targetbuf) cxListRemoveAndGetFirst((list), (targetbuf)) |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
679 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
680 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
681 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
682 | * Removes and returns the last element of the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
683 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
684 | * No destructor is called, and instead the element is copied to the |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
685 | * @p targetbuf which MUST be large enough to hold the removed element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
686 | * If the list is storing pointers, only the pointer is copied to @p targetbuf. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
687 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
688 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
689 | * @param targetbuf a buffer where to copy the element |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
690 | * @retval zero success |
| 112 | 691 | * @retval non-zero the list is empty |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
692 | */ |
| 113 | 693 | cx_attr_nonnull cx_attr_access_w(2) |
| 694 | CX_EXPORT int cxListRemoveAndGetLast(CxList *list, void *targetbuf); | |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
695 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
696 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
697 | * Removes and returns the last element of the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
698 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
699 | * Alias for cxListRemoveAndGetLast(). |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
700 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
701 | * No destructor is called, and instead the element is copied to the |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
702 | * @p targetbuf which MUST be large enough to hold the removed element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
703 | * If the list is storing pointers, only the pointer is copied to @p targetbuf. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
704 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
705 | * @param list (@c CxList*) the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
706 | * @param targetbuf (@c void*) a buffer where to copy the element |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
707 | * @retval zero success |
| 112 | 708 | * @retval non-zero the list is empty |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
709 | * @see cxListRemoveAndGetLast() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
710 | * @see cxListPopFront() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
711 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
712 | #define cxListPop(list, targetbuf) cxListRemoveAndGetLast((list), (targetbuf)) |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
713 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
714 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
715 | * Removes multiple element starting at the specified index. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
716 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
717 | * If an element destructor function is specified, it is called for each |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
718 | * element. It is guaranteed that the destructor is called before removing |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
719 | * the element. However, due to possible optimizations, it is neither guaranteed |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
720 | * that the destructors are invoked for all elements before starting to remove |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
721 | * them, nor that the element is removed immediately after the destructor call |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
722 | * before proceeding to the next element. |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
723 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
724 | * @param list the list |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
725 | * @param index the index of the element |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
726 | * @param num the number of elements to remove |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
727 | * @return the actual number of removed elements |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
728 | */ |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
729 | cx_attr_nonnull |
| 113 | 730 | CX_EXPORT size_t cxListRemoveArray(CxList *list, size_t index, size_t num); |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
731 | |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
732 | /** |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
733 | * Removes and returns multiple elements starting at the specified index. |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
734 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
735 | * No destructor is called, and instead the elements are copied to the |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
736 | * @p targetbuf which MUST be large enough to hold all removed elements. |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
737 | * If the list is storing pointers, @p targetbuf is expected to be an array of pointers. |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
738 | * |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
739 | * @param list the list |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
740 | * @param index the index of the element |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
741 | * @param num the number of elements to remove |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
742 | * @param targetbuf a buffer where to copy the elements |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
743 | * @return the actual number of removed elements |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
744 | */ |
| 113 | 745 | cx_attr_nonnull cx_attr_access_w(4) |
| 746 | CX_EXPORT size_t cxListRemoveArrayAndGet(CxList *list, size_t index, size_t num, void *targetbuf); | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
747 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
748 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
749 | * Removes all elements from this list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
750 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
751 | * If element destructor functions are specified, they are called for each |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
752 | * element before removing them. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
753 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
754 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
755 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
756 | cx_attr_nonnull |
| 113 | 757 | CX_EXPORT void cxListClear(CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
758 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
759 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
760 | * Swaps two items in the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
761 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
762 | * Implementations should only allocate temporary memory for the swap if |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
763 | * it is necessary. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
764 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
765 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
766 | * @param i the index of the first element |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
767 | * @param j the index of the second element |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
768 | * @retval zero success |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
769 | * @retval non-zero one of the indices is out of bounds, |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
770 | * or the swap needed extra memory, but allocation failed |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
771 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
772 | cx_attr_nonnull |
| 113 | 773 | CX_EXPORT int cxListSwap(CxList *list, size_t i, size_t j); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
774 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
775 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
776 | * Returns a pointer to the element at the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
777 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
778 | * If the list is storing pointers, returns the pointer stored at the specified index. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
779 | * |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
780 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
781 | * @param index the index of the element |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
782 | * @return a pointer to the element or @c NULL if the index is out of bounds |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
783 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
784 | cx_attr_nonnull |
| 113 | 785 | CX_EXPORT void *cxListAt(const CxList *list, size_t index); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
786 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
787 | /** |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
788 | * Returns a pointer to the first element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
789 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
790 | * If the list is storing pointers, returns the first pointer stored in the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
791 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
792 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
793 | * @return a pointer to the first element or @c NULL if the list is empty |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
794 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
795 | cx_attr_nonnull |
| 113 | 796 | CX_EXPORT void *cxListFirst(const CxList *list); |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
797 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
798 | /** |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
799 | * Returns a pointer to the last element. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
800 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
801 | * If the list is storing pointers, returns the last pointer stored in the list. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
802 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
803 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
804 | * @return a pointer to the last element or @c NULL if the list is empty |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
805 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
806 | cx_attr_nonnull |
| 113 | 807 | CX_EXPORT void *cxListLast(const CxList *list); |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
808 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
809 | /** |
| 113 | 810 | * Sets the element at the specified index in the list. |
| 811 | * | |
| 812 | * This overwrites the element in-place without calling any destructor | |
| 813 | * on the overwritten element. | |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
814 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
815 | * @param list the list to set the element in |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
816 | * @param index the index to set the element at |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
817 | * @param elem element to set |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
818 | * @retval zero on success |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
819 | * @retval non-zero when index is out of bounds |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
820 | */ |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
821 | cx_attr_nonnull |
| 113 | 822 | CX_EXPORT int cxListSet(CxList *list, size_t index, const void *elem); |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
823 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
824 | /** |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
825 | * Returns an iterator pointing to the item at the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
826 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
827 | * The returned iterator is position-aware. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
828 | * |
| 112 | 829 | * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
830 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
831 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
832 | * @param index the index where the iterator shall point at |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
833 | * @return a new iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
834 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
835 | cx_attr_nodiscard |
| 113 | 836 | CX_EXPORT CxIterator cxListIteratorAt(const CxList *list, size_t index); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
837 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
838 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
839 | * Returns a backwards iterator pointing to the item at the specified index. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
840 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
841 | * The returned iterator is position-aware. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
842 | * |
| 112 | 843 | * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
844 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
845 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
846 | * @param index the index where the iterator shall point at |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
847 | * @return a new iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
848 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
849 | cx_attr_nodiscard |
| 113 | 850 | CX_EXPORT CxIterator cxListBackwardsIteratorAt(const CxList *list, size_t index); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
851 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
852 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
853 | * Returns an iterator pointing to the first item of the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
854 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
855 | * The returned iterator is position-aware. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
856 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
857 | * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
858 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
859 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
860 | * @return a new iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
861 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
862 | cx_attr_nodiscard |
| 113 | 863 | CX_EXPORT CxIterator cxListIterator(const CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
864 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
865 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
866 | * Returns a backwards iterator pointing to the last item of the list. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
867 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
868 | * The returned iterator is position-aware. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
869 | * |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
870 | * If the list is empty or @c NULL, a past-the-end iterator will be returned. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
871 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
872 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
873 | * @return a new iterator |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
874 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
875 | cx_attr_nodiscard |
| 113 | 876 | CX_EXPORT CxIterator cxListBackwardsIterator(const CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
877 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
878 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
879 | * Returns the index of the first element that equals @p elem. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
880 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
881 | * Determining equality is performed by the list's comparator function. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
882 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
883 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
884 | * @param elem the element to find |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
885 | * @return the index of the element or the size of the list when the element is not found |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
886 | * @see cxListIndexValid() |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
887 | * @see cxListContains() |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
888 | */ |
| 113 | 889 | cx_attr_nonnull cx_attr_nodiscard |
| 890 | CX_EXPORT size_t cxListFind(const CxList *list, const void *elem); | |
|
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
891 | |
|
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
892 | /** |
| 112 | 893 | * Checks if the list contains the specified element. |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
894 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
895 | * The elements are compared with the list's comparator function. |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
896 | * |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
897 | * @param list the list |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
898 | * @param elem the element to find |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
899 | * @retval true if the element is contained |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
900 | * @retval false if the element is not contained |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
901 | * @see cxListFind() |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
902 | */ |
| 113 | 903 | cx_attr_nonnull cx_attr_nodiscard |
| 904 | CX_EXPORT bool cxListContains(const CxList* list, const void* elem); | |
|
108
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
905 | |
|
77254bd6dccb
update toolkit, adjust UI code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
906 | /** |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
907 | * Checks if the specified index is within bounds. |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
908 | * |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
909 | * @param list the list |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
910 | * @param index the index |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
911 | * @retval true if the index is within bounds |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
912 | * @retval false if the index is out of bounds |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
913 | */ |
| 113 | 914 | cx_attr_nonnull cx_attr_nodiscard |
| 915 | CX_EXPORT bool cxListIndexValid(const CxList *list, size_t index); | |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
916 | |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
917 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
918 | * Removes and returns the index of the first element that equals @p elem. |
|
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
919 | * |
|
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
920 | * Determining equality is performed by the list's comparator function. |
|
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
921 | * |
|
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
922 | * @param list the list |
|
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
923 | * @param elem the element to find and remove |
|
102
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
924 | * @return the index of the now removed element or the list size |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
925 | * when the element is not found or could not be removed |
|
64ded9f6a6c6
update libs (ucx, toolkit, libidav)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
926 | * @see cxListIndexValid() |
|
2
fbdfaacc4182
update ucx, libidav and add first gui code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
0
diff
changeset
|
927 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
928 | cx_attr_nonnull |
| 113 | 929 | CX_EXPORT size_t cxListFindRemove(CxList *list, const void *elem); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
930 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
931 | /** |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
932 | * Sorts the list. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
933 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
934 | * @remark The underlying sort algorithm is implementation defined. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
935 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
936 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
937 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
938 | cx_attr_nonnull |
| 113 | 939 | CX_EXPORT void cxListSort(CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
940 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
941 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
942 | * Reverses the order of the items. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
943 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
944 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
945 | */ |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
946 | cx_attr_nonnull |
| 113 | 947 | CX_EXPORT void cxListReverse(CxList *list); |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
948 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
949 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
950 | * Compares a list to another list of the same type. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
951 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
952 | * First, the list sizes are compared. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
953 | * If they match, the lists are compared element-wise. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
954 | * |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
955 | * @param list the list |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
956 | * @param other the list to compare to |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
957 | * @retval zero both lists are equal element wise |
| 113 | 958 | * @retval negative the first list is smaller, |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
959 | * or the first non-equal element in the first list is smaller |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
960 | * @retval positive the first list is larger |
|
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
961 | * or the first non-equal element in the first list is larger |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
962 | */ |
| 113 | 963 | cx_attr_nonnull cx_attr_nodiscard |
| 964 | CX_EXPORT int cxListCompare(const CxList *list, const CxList *other); | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
965 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
966 | /** |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
967 | * Deallocates the memory of the specified list structure. |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
968 | * |
|
101
7b3a3130be44
update ucx, toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
49
diff
changeset
|
969 | * Also calls the content destructor functions for each element, if specified. |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
970 | * |
| 112 | 971 | * @param list the list that shall be freed |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
972 | */ |
| 113 | 973 | CX_EXPORT void cxListFree(CxList *list); |
| 974 | ||
| 975 | ||
| 976 | /** | |
| 977 | * Performs a deep clone of one list into another. | |
| 978 | * | |
| 979 | * If the destination list already contains elements, the cloned elements | |
| 980 | * are appended to that list. | |
| 981 | * | |
| 982 | * @attention If the cloned elements need to be destroyed by a destructor | |
| 983 | * function, you must make sure that the destination list also uses this | |
| 984 | * destructor function. | |
| 985 | * | |
| 986 | * @param dst the destination list | |
| 987 | * @param src the source list | |
| 988 | * @param clone_func the clone function for the elements | |
| 989 | * @param clone_allocator the allocator that is passed to the clone function | |
| 990 | * @param data optional additional data that is passed to the clone function | |
| 991 | * @retval zero when all elements were successfully cloned | |
| 992 | * @retval non-zero when an allocation error occurred | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
993 | * @see cxListCloneShallow() |
| 113 | 994 | */ |
| 995 | cx_attr_nonnull_arg(1, 2, 3) | |
| 996 | CX_EXPORT int cxListClone(CxList *dst, const CxList *src, | |
| 997 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); | |
| 998 | ||
| 999 | /** | |
| 1000 | * Clones elements from a list only if they are not present in another list. | |
| 1001 | * | |
| 1002 | * If the @p minuend does not contain duplicates, this is equivalent to adding | |
| 1003 | * the set difference to the destination list. | |
| 1004 | * | |
| 1005 | * This function is optimized for the case when both the @p minuend and the | |
| 1006 | * @p subtrahend are sorted. | |
| 1007 | * | |
| 1008 | * @param dst the destination list | |
| 1009 | * @param minuend the list to subtract elements from | |
| 1010 | * @param subtrahend the elements that shall be subtracted | |
| 1011 | * @param clone_func the clone function for the elements | |
| 1012 | * @param clone_allocator the allocator that is passed to the clone function | |
| 1013 | * @param data optional additional data that is passed to the clone function | |
| 1014 | * @retval zero when the elements were successfully cloned | |
| 1015 | * @retval non-zero when an allocation error occurred | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1016 | * @see cxListDifferenceShallow() |
| 113 | 1017 | */ |
| 1018 | cx_attr_nonnull_arg(1, 2, 3, 4) | |
| 1019 | CX_EXPORT int cxListDifference(CxList *dst, | |
| 1020 | const CxList *minuend, const CxList *subtrahend, | |
| 1021 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); | |
| 1022 | ||
| 1023 | /** | |
| 1024 | * Clones elements from a list only if they are also present in another list. | |
| 1025 | * | |
| 1026 | * This function is optimized for the case when both the @p src and the | |
| 1027 | * @p other list are sorted. | |
| 1028 | * | |
| 1029 | * If the destination list already contains elements, the intersection is appended | |
| 1030 | * to that list. | |
| 1031 | * | |
| 1032 | * @param dst the destination list | |
| 1033 | * @param src the list to clone the elements from | |
| 1034 | * @param other the list to check the elements for existence | |
| 1035 | * @param clone_func the clone function for the elements | |
| 1036 | * @param clone_allocator the allocator that is passed to the clone function | |
| 1037 | * @param data optional additional data that is passed to the clone function | |
| 1038 | * @retval zero when the elements were successfully cloned | |
| 1039 | * @retval non-zero when an allocation error occurred | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1040 | * @see cxListIntersectionShallow() |
| 113 | 1041 | */ |
| 1042 | cx_attr_nonnull_arg(1, 2, 3, 4) | |
| 1043 | CX_EXPORT int cxListIntersection(CxList *dst, const CxList *src, const CxList *other, | |
| 1044 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); | |
| 1045 | ||
| 1046 | /** | |
| 1047 | * Performs a deep clone of one list into another, skipping duplicates. | |
| 1048 | * | |
| 1049 | * This function is optimized for the case when both the @p src and the | |
| 1050 | * @p other list are sorted. | |
| 1051 | * In that case, the union will also be sorted. | |
| 1052 | * | |
| 1053 | * If the destination list already contains elements, the union is appended | |
| 1054 | * to that list. In that case the destination is not necessarily sorted. | |
| 1055 | * | |
| 1056 | * @param dst the destination list | |
| 1057 | * @param src the primary source list | |
| 1058 | * @param other the other list, where elements are only cloned from | |
| 1059 | * when they are not in @p src | |
| 1060 | * @param clone_func the clone function for the elements | |
| 1061 | * @param clone_allocator the allocator that is passed to the clone function | |
| 1062 | * @param data optional additional data that is passed to the clone function | |
| 1063 | * @retval zero when the elements were successfully cloned | |
| 1064 | * @retval non-zero when an allocation error occurred | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1065 | * @see cxListUnionShallow() |
| 113 | 1066 | */ |
| 1067 | cx_attr_nonnull_arg(1, 2, 3, 4) | |
| 1068 | CX_EXPORT int cxListUnion(CxList *dst, const CxList *src, const CxList *other, | |
| 1069 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1070 | |
| 113 | 1071 | /** |
| 1072 | * Performs a shallow clone of one list into another. | |
| 1073 | * | |
| 1074 | * This function uses the default allocator, if needed, and performs | |
| 1075 | * shallow clones with @c memcpy(). | |
| 1076 | * | |
| 1077 | * If the destination list already contains elements, the cloned elements | |
| 1078 | * are appended to that list. | |
| 1079 | * | |
| 1080 | * @attention If the cloned elements need to be destroyed by a destructor | |
| 1081 | * function, you must make sure that the destination list also uses this | |
| 1082 | * destructor function. | |
| 1083 | * | |
| 1084 | * @param dst the destination list | |
| 1085 | * @param src the source list | |
| 1086 | * @retval zero when all elements were successfully cloned | |
| 1087 | * @retval non-zero when an allocation error occurred | |
| 1088 | * @see cxListClone() | |
| 1089 | */ | |
| 1090 | cx_attr_nonnull | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1091 | CX_EXPORT int cxListCloneShallow(CxList *dst, const CxList *src); |
| 113 | 1092 | |
| 1093 | /** | |
| 1094 | * Clones elements from a list only if they are not present in another list. | |
| 1095 | * | |
| 1096 | * This function uses the default allocator, if needed, and performs | |
| 1097 | * shallow clones with @c memcpy(). | |
| 1098 | * | |
| 1099 | * If the @p minuend does not contain duplicates, this is equivalent to adding | |
| 1100 | * the set difference to the destination list. | |
| 1101 | * | |
| 1102 | * This function is optimized for the case when both the @p minuend and the | |
| 1103 | * @p subtrahend are sorted. | |
| 1104 | * | |
| 1105 | * @param dst the destination list | |
| 1106 | * @param minuend the list to subtract elements from | |
| 1107 | * @param subtrahend the elements that shall be subtracted | |
| 1108 | * @retval zero when the elements were successfully cloned | |
| 1109 | * @retval non-zero when an allocation error occurred | |
| 1110 | * @see cxListDifference() | |
| 1111 | */ | |
| 1112 | cx_attr_nonnull | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1113 | CX_EXPORT int cxListDifferenceShallow(CxList *dst, |
| 113 | 1114 | const CxList *minuend, const CxList *subtrahend); |
| 1115 | ||
| 1116 | /** | |
| 1117 | * Clones elements from a list only if they are also present in another list. | |
| 1118 | * | |
| 1119 | * This function uses the default allocator, if needed, and performs | |
| 1120 | * shallow clones with @c memcpy(). | |
| 1121 | * | |
| 1122 | * This function is optimized for the case when both the @p src and the | |
| 1123 | * @p other list are sorted. | |
| 1124 | * | |
| 1125 | * If the destination list already contains elements, the intersection is appended | |
| 1126 | * to that list. | |
| 1127 | * | |
| 1128 | * @param dst the destination list | |
| 1129 | * @param src the list to clone the elements from | |
| 1130 | * @param other the list to check the elements for existence | |
| 1131 | * @retval zero when the elements were successfully cloned | |
| 1132 | * @retval non-zero when an allocation error occurred | |
| 1133 | * @see cxListIntersection() | |
| 1134 | */ | |
| 1135 | cx_attr_nonnull | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1136 | CX_EXPORT int cxListIntersectionShallow(CxList *dst, const CxList *src, const CxList *other); |
| 113 | 1137 | |
| 1138 | /** | |
| 1139 | * Performs a deep clone of one list into another, skipping duplicates. | |
| 1140 | * | |
| 1141 | * This function uses the default allocator, if needed, and performs | |
| 1142 | * shallow clones with @c memcpy(). | |
| 1143 | * | |
| 1144 | * This function is optimized for the case when both the @p src and the | |
| 1145 | * @p other list are sorted. | |
| 1146 | * In that case, the union will also be sorted. | |
| 1147 | * | |
| 1148 | * If the destination list already contains elements, the union is appended | |
| 1149 | * to that list. In that case the destination is not necessarily sorted. | |
| 1150 | * | |
| 1151 | * @param dst the destination list | |
| 1152 | * @param src the primary source list | |
| 1153 | * @param other the other list, where elements are only cloned from | |
| 1154 | * when they are not in @p src | |
| 1155 | * @retval zero when the elements were successfully cloned | |
| 1156 | * @retval non-zero when an allocation error occurred | |
| 1157 | * @see cxListUnion() | |
| 1158 | */ | |
| 1159 | cx_attr_nonnull | |
|
117
b174e721663e
update toolkit, ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
113
diff
changeset
|
1160 | CX_EXPORT int cxListUnionShallow(CxList *dst, const CxList *src, const CxList *other); |
| 113 | 1161 | |
| 1162 | /** | |
| 1163 | * Asks the list to reserve enough memory for a given total number of elements. | |
| 1164 | * | |
| 1165 | * List implementations are free to choose if reserving memory upfront makes | |
| 1166 | * sense. | |
| 1167 | * For example, array-based implementations usually do support reserving memory | |
| 1168 | * for additional elements while linked lists usually don't. | |
| 1169 | * | |
| 1170 | * @note When the requested capacity is smaller than the current size, | |
| 1171 | * this function returns zero without performing any action. | |
| 1172 | * | |
| 1173 | * @param list the list | |
| 1174 | * @param capacity the expected total number of elements | |
| 1175 | * @retval zero on success or when overallocation is not supported | |
| 1176 | * @retval non-zero when an allocation error occurred | |
| 1177 | * @see cxListShrink() | |
| 1178 | */ | |
| 1179 | cx_attr_nonnull | |
| 1180 | CX_EXPORT int cxListReserve(CxList *list, size_t capacity); | |
| 1181 | ||
| 1182 | /** | |
| 1183 | * Advises the list to free any overallocated memory. | |
| 1184 | * | |
| 1185 | * Lists that do not support overallocation simply return zero. | |
| 1186 | * | |
| 1187 | * This function usually returns zero, except for very special and custom | |
| 1188 | * list and/or allocator implementations where freeing memory can fail. | |
| 1189 | * | |
| 1190 | * @param list the list | |
| 1191 | * @return usually zero | |
| 1192 | */ | |
| 1193 | cx_attr_nonnull | |
| 1194 | CX_EXPORT int cxListShrink(CxList *list); | |
|
0
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1195 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1196 | #ifdef __cplusplus |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1197 | } // extern "C" |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1198 | #endif |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1199 | |
|
2483f517c562
add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1200 | #endif // UCX_LIST_H |