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