ucx/cx/list.h

Sat, 08 Nov 2025 23:06:11 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 08 Nov 2025 23:06:11 +0100
changeset 888
af685cc9d623
parent 854
1c8401ece69e
permissions
-rw-r--r--

update ucx

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

mercurial