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