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