Wed, 31 Dec 2025 16:41:16 +0100
update ucx to version 4.0
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | /** |
| 852 | 29 | * @file map.h |
| 30 | * @brief Interface for map implementations. | |
| 31 | * @author Mike Becker | |
| 32 | * @author Olaf Wintermann | |
| 33 | * @copyright 2-Clause BSD License | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #ifndef UCX_MAP_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_MAP_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 | #include "string.h" |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | #include "hash_key.h" |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
| 889 | 44 | #ifndef UCX_LIST_H |
| 45 | // forward-declare CxList | |
| 46 | typedef struct cx_list_s CxList; | |
| 47 | #endif | |
| 48 | ||
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | /** Type for the UCX map. */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | typedef struct cx_map_s CxMap; |
|
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 | /** Type for a map entry. */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | typedef struct cx_map_entry_s CxMapEntry; |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
55 | /** Type for a map iterator. */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
56 | typedef struct cx_map_iterator_s CxMapIterator; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
57 | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | /** Type for map class definitions. */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | typedef struct cx_map_class_s cx_map_class; |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | /** Structure for the UCX map. */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | struct cx_map_s { |
|
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
63 | /** |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
64 | * Base attributes. |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
65 | */ |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
66 | 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
|
67 | /** The map class definition. */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | cx_map_class *cl; |
|
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 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | /** |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
72 | * A map entry. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
73 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
74 | struct cx_map_entry_s { |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
75 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
76 | * A pointer to the key. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
77 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
78 | const CxHashKey *key; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
79 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
80 | * A pointer to the value. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
81 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
82 | void *value; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
83 | }; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
84 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
85 | /** |
| 750 | 86 | * The type of iterator for a map. |
| 87 | */ | |
| 88 | enum cx_map_iterator_type { | |
| 89 | /** | |
| 90 | * Iterates over key/value pairs. | |
| 91 | */ | |
| 92 | CX_MAP_ITERATOR_PAIRS, | |
| 93 | /** | |
| 94 | * Iterates over keys only. | |
| 95 | */ | |
| 96 | CX_MAP_ITERATOR_KEYS, | |
| 97 | /** | |
| 98 | * Iterates over values only. | |
| 99 | */ | |
| 100 | CX_MAP_ITERATOR_VALUES | |
| 101 | }; | |
| 102 | ||
| 103 | /** | |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
104 | * Internal iterator struct - use CxMapIterator. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
105 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
106 | struct cx_map_iterator_s { |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
107 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
108 | * Inherited common data for all iterators. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
109 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
110 | CX_ITERATOR_BASE; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
111 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
112 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
113 | * Handle for the source map. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
114 | */ |
| 889 | 115 | CxMap *map; |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
116 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
117 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
118 | * Handle for the current element. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
119 | * |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
120 | * @attention Depends on the map implementation, do not assume a type (better: do not use!). |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
121 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
122 | void *elem; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
123 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
124 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
125 | * Reserved memory for a map entry. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
126 | * |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
127 | * If a map implementation uses an incompatible layout, the iterator needs something |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
128 | * to point to during iteration which @em is compatible. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
129 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
130 | CxMapEntry entry; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
131 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
132 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
133 | * Field for storing the current slot number. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
134 | * |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
135 | * (Used internally) |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
136 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
137 | size_t slot; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
138 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
139 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
140 | * Counts the elements successfully. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
141 | * It usually does not denote a stable index within the map as it would be for arrays. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
142 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
143 | size_t index; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
144 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
145 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
146 | * The size of a value stored in this map. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
147 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
148 | size_t elem_size; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
149 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
150 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
151 | * May contain the total number of elements, if known. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
152 | * Set to @c SIZE_MAX when the total number is unknown during iteration. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
153 | * |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
154 | * @remark The UCX implementations of #CxMap always know the number of elements they store. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
155 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
156 | size_t elem_count; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
157 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
158 | /** |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
159 | * The type of this iterator. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
160 | */ |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
161 | enum cx_map_iterator_type type; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
162 | }; |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
163 | |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
164 | /** |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | * The class definition for arbitrary maps. |
|
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 | struct cx_map_class_s { |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | * Deallocates the entire memory. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | */ |
| 852 | 171 | void (*deallocate)(struct cx_map_s *map); |
|
747
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 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | * Removes all elements. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | */ |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | void (*clear)(struct cx_map_s *map); |
|
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 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | * Add or overwrite an element. |
| 886 | 180 | * If the @p value is @c NULL, the implementation |
| 181 | * shall only allocate memory instead of adding an existing value to the map. | |
| 891 | 182 | * Returns a map entry where the pointer to the key is @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
|
183 | */ |
| 891 | 184 | CxMapEntry (*put)(CxMap *map, CxHashKey key, void *value); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | * Returns an element. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | */ |
| 889 | 189 | void *(*get)(const CxMap *map, CxHashKey key); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | * Removes an element. |
| 852 | 193 | * |
| 194 | * Implementations SHALL check if @p targetbuf is set and copy the elements | |
| 195 | * to the buffer without invoking any destructor. | |
| 196 | * When @p targetbuf is not set, the destructors SHALL be invoked. | |
| 197 | * | |
| 198 | * The function SHALL return zero when the @p key was found and | |
| 199 | * non-zero, otherwise. | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | */ |
| 889 | 201 | int (*remove)(CxMap *map, CxHashKey key, 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
|
202 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | /** |
| 750 | 204 | * Creates an iterator for this map. |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | */ |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
206 | CxMapIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | }; |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | |
| 775 | 209 | /** |
| 210 | * A shared instance of an empty map. | |
| 211 | * | |
| 852 | 212 | * Writing to that map is not allowed. |
| 213 | * | |
| 889 | 214 | * You can use this as a placeholder for initializing CxMap pointers |
| 852 | 215 | * for which you do not want to reserve memory right from the beginning. |
| 775 | 216 | */ |
| 889 | 217 | CX_EXPORT extern CxMap *const cxEmptyMap; |
| 750 | 218 | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | * Deallocates the memory of the specified map. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | * |
| 852 | 222 | * Also calls the content destructor functions for each element, if specified. |
| 223 | * | |
| 224 | * @param map the map to 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
|
225 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
226 | CX_EXTERN |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
227 | void cxMapFree(CxMap *map); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | * Clears a map by 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
|
231 | * |
| 852 | 232 | * Also calls the content destructor functions for each element, if specified. |
| 233 | * | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | * @param map the map to be cleared |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
236 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
237 | void cxMapClear(CxMap *map); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | |
|
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
239 | /** |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
240 | * Returns the number of elements in this map. |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
241 | * |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
242 | * @param map the map |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
243 | * @return the number of stored elements |
|
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
244 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
245 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
246 | size_t cxMapSize(const CxMap *map); |
|
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
775
diff
changeset
|
247 | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | * Creates a value iterator for a map. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | * |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
251 | * When the map is storing pointers, those pointers are returned. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
252 | * Otherwise, the iterator iterates over pointers to the memory within the map where the |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
253 | * respective elements are stored. |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
254 | * |
| 852 | 255 | * @note An iterator iterates over all elements successively. Therefore, the order |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
256 | * highly depends on the map implementation and may change arbitrarily when the contents change. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
257 | * |
| 886 | 258 | * @param map the map to create the iterator for (can be @c NULL) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
259 | * @return an iterator for the currently stored values |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
260 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
261 | CX_EXTERN CX_NODISCARD |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
262 | CxMapIterator cxMapIteratorValues(const CxMap *map); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
263 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
264 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
265 | * Creates a key iterator for a map. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
266 | * |
| 889 | 267 | * The elements of the iterator are keys of type CxHashKey, and the pointer returned |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
268 | * during iterator shall be treated as @c const @c CxHashKey* . |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
269 | * |
| 852 | 270 | * @note An iterator iterates over all elements successively. Therefore, the order |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
271 | * highly depends on the map implementation and may change arbitrarily when the contents change. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
272 | * |
| 886 | 273 | * @param map the map to create the iterator for (can be @c NULL) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
274 | * @return an iterator for the currently stored keys |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
276 | CX_EXTERN CX_NODISCARD |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
277 | CxMapIterator cxMapIteratorKeys(const CxMap *map); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
279 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
280 | * Creates an iterator for a map. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
281 | * |
| 889 | 282 | * The elements of the iterator are key/value pairs of type CxMapEntry, and the pointer returned |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
283 | * during iterator shall be treated as @c const @c CxMapEntry* . |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | * |
| 852 | 285 | * @note An iterator iterates over all elements successively. Therefore, the order |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
286 | * highly depends on the map implementation and may change arbitrarily when the contents change. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
287 | * |
| 886 | 288 | * @param map the map to create the iterator for (can be @c NULL) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
289 | * @return an iterator for the currently stored entries |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
290 | * @see cxMapIteratorKeys() |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
291 | * @see cxMapIteratorValues() |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
292 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
293 | CX_EXTERN CX_NODISCARD |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
294 | CxMapIterator cxMapIterator(const CxMap *map); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | /** |
| 889 | 297 | * Puts a key/value-pair into the map. |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
298 | * |
| 889 | 299 | * A possible existing value will be overwritten. |
| 300 | * If destructor functions are specified, they are called for | |
| 301 | * the overwritten element. | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
302 | * |
| 889 | 303 | * If this map is storing pointers, the @p value pointer is written |
| 304 | * to the map. Otherwise, the memory is copied from @p value with | |
| 305 | * memcpy(). | |
| 306 | * | |
| 307 | * The @p key is always copied. | |
| 308 | * | |
| 309 | * @param map the map | |
| 310 | * @param key the key | |
| 311 | * @param value the value | |
| 312 | * @retval zero success | |
| 313 | * @retval non-zero value on memory allocation failure | |
| 314 | * @see cxMapPut() | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
315 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
316 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
317 | int cx_map_put(CxMap *map, CxHashKey key, void *value); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
318 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
319 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | * Puts a key/value-pair into the map. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
321 | * |
| 852 | 322 | * A possible existing value will be overwritten. |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
323 | * If destructor functions are specified, they are called for |
|
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
324 | * the overwritten element. |
| 852 | 325 | * |
| 326 | * If this map is storing pointers, the @p value pointer is written | |
| 327 | * to the map. Otherwise, the memory is copied from @p value with | |
| 328 | * memcpy(). | |
| 329 | * | |
| 330 | * The @p key is always copied. | |
| 331 | * | |
| 332 | * @param map (@c CxMap*) the map | |
| 889 | 333 | * @param key (any supported key type) the key |
| 852 | 334 | * @param value (@c void*) the value |
| 335 | * @retval zero success | |
| 336 | * @retval non-zero value on memory allocation failure | |
| 889 | 337 | * @see CX_HASH_KEY() |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
338 | */ |
| 889 | 339 | #define cxMapPut(map, key, value) cx_map_put(map, CX_HASH_KEY(key), value) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
340 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | /** |
| 889 | 342 | * Allocates memory for a value in the map associated with the specified key. |
| 343 | * | |
| 344 | * A possible existing value will be overwritten. | |
| 345 | * If destructor functions are specified, they are called for | |
| 346 | * the overwritten element. | |
| 347 | * | |
| 348 | * If the map is storing pointers, this function returns a @c void** pointer, | |
| 349 | * meaning a pointer to that pointer. | |
| 350 | * | |
| 351 | * The @p key is always copied. | |
| 352 | * | |
| 353 | * @param map the map | |
| 354 | * @param key the key | |
| 355 | * @return the pointer to the allocated memory or @c NULL if allocation fails | |
| 356 | * @see cxMapEmplace() | |
| 886 | 357 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
358 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
359 | void *cx_map_emplace(CxMap *map, CxHashKey key); |
| 886 | 360 | |
| 361 | /** | |
| 362 | * Allocates memory for a value in the map associated with the specified key. | |
| 363 | * | |
| 364 | * A possible existing value will be overwritten. | |
| 365 | * If destructor functions are specified, they are called for | |
| 366 | * the overwritten element. | |
| 367 | * | |
| 368 | * If the map is storing pointers, this function returns a @c void** pointer, | |
| 369 | * meaning a pointer to that pointer. | |
| 370 | * | |
| 371 | * The @p key is always copied. | |
| 372 | * | |
| 373 | * @param map (@c CxMap*) the map | |
| 889 | 374 | * @param key (any supported key type) the key |
| 886 | 375 | * @return the pointer to the allocated memory or @c NULL if allocation fails |
| 889 | 376 | * @see CX_HASH_KEY() |
| 886 | 377 | */ |
| 889 | 378 | #define cxMapEmplace(map, key) cx_map_emplace(map, CX_HASH_KEY(key)) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
379 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
380 | /** |
| 889 | 381 | * Retrieves a value by using a key. |
| 382 | * | |
| 383 | * If this map is storing pointers, the stored pointer is returned. | |
| 384 | * Otherwise, a pointer to the element within the map's memory | |
| 385 | * is returned (which is valid as long as the element stays in the map). | |
| 386 | * | |
| 387 | * @param map the map | |
| 388 | * @param key the key | |
| 389 | * @return the value | |
| 390 | * @see cxMapGet() | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
391 | */ |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
392 | CX_EXTERN CX_NONNULL CX_NODISCARD |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
393 | void *cx_map_get(const CxMap *map, CxHashKey key); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
394 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
395 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | * Retrieves a value by using a key. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
397 | * |
| 852 | 398 | * If this map is storing pointers, the stored pointer is returned. |
| 399 | * Otherwise, a pointer to the element within the map's memory | |
| 400 | * is returned (which is valid as long as the element stays in the map). | |
| 401 | * | |
| 402 | * @param map (@c CxMap*) the map | |
| 889 | 403 | * @param key (any supported key type) the key |
| 404 | * @return (@c void*) the value or @c NULL when no value with that @p key exists | |
| 405 | * @see CX_HASH_KEY() | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
406 | */ |
| 889 | 407 | #define cxMapGet(map, key) cx_map_get(map, CX_HASH_KEY(key)) |
| 852 | 408 | |
| 409 | /** | |
| 889 | 410 | * Checks if a map contains a specific key. |
| 411 | * | |
| 412 | * @param map (@c CxMap*) the map | |
| 413 | * @param key (any supported key type) the key | |
| 414 | * @retval true if the key exists in the map | |
| 415 | * @retval false if the key does not exist in the map | |
| 416 | * @see CX_HASH_KEY() | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
417 | */ |
| 889 | 418 | #define cxMapContains(map, key) (cxMapGet(map, key) != NULL) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
419 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
421 | * Removes a key/value-pair from the map by using the key. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
422 | * |
| 889 | 423 | * Invokes the destructor functions, if any, on the removed element if and only if the |
| 424 | * @p targetbuf is @c NULL. | |
| 425 | * | |
| 426 | * @param map the map | |
| 427 | * @param key the key | |
| 428 | * @param targetbuf the optional buffer where the removed element shall be copied to | |
| 429 | * @retval zero success | |
| 430 | * @retval non-zero the key was not found | |
| 431 | * | |
| 432 | * @see cxMapRemove() | |
| 433 | * @see cxMapRemoveAndGet() | |
| 434 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
435 | CX_EXTERN CX_NONNULL_ARG(1) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
436 | int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf); |
| 889 | 437 | |
| 438 | /** | |
| 439 | * Removes a key/value-pair from the map by using the key. | |
| 440 | * | |
| 441 | * Always invokes the destructor functions, if any, on the removed element. | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
442 | * |
| 852 | 443 | * @param map (@c CxMap*) the map |
| 889 | 444 | * @param key (any supported key type) the key |
| 852 | 445 | * @retval zero success |
| 446 | * @retval non-zero the key was not found | |
| 447 | * | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
448 | * @see cxMapRemoveAndGet() |
| 889 | 449 | * @see CX_HASH_KEY() |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
450 | */ |
| 889 | 451 | #define cxMapRemove(map, key) cx_map_remove(map, CX_HASH_KEY(key), NULL) |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
452 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
453 | /** |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
454 | * Removes a key/value-pair from the map by using the key. |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
455 | * |
| 852 | 456 | * This function will copy the contents of the removed element |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
457 | * to the target buffer, which must be guaranteed to be large enough |
| 852 | 458 | * to hold the element (the map's element size). |
| 459 | * The destructor functions, if any, will @em not be called. | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
460 | * |
| 852 | 461 | * If this map is storing pointers, the element is the pointer itself |
| 462 | * and not the object it points to. | |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
463 | * |
| 852 | 464 | * @param map (@c CxMap*) the map |
| 889 | 465 | * @param key (any supported key type) the key |
| 852 | 466 | * @param targetbuf (@c void*) the buffer where the element shall be copied to |
| 467 | * @retval zero success | |
| 468 | * @retval non-zero the key was not found | |
|
854
1c8401ece69e
update ucx to version 3.1
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
852
diff
changeset
|
469 | * |
| 852 | 470 | * @see cxMapRemove() |
| 889 | 471 | * @see CX_HASH_KEY() |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
472 | */ |
| 889 | 473 | #define cxMapRemoveAndGet(map, key, targetbuf) cx_map_remove(map, CX_HASH_KEY(key), targetbuf) |
| 474 | ||
| 475 | /** | |
| 476 | * Performs a deep clone of one map into another. | |
| 477 | * | |
| 478 | * If the destination map already contains entries, the cloned entries | |
| 479 | * are added to that map, possibly overwriting existing elements when | |
| 480 | * the keys already exist. | |
| 481 | * | |
| 482 | * When elements in the destination map need to be replaced, any destructor | |
| 483 | * function is called on the replaced elements before replacing them. | |
| 484 | * | |
| 485 | * @attention If the cloned elements need to be destroyed by a destructor | |
| 486 | * function, you must make sure that the destination map also uses this | |
| 487 | * destructor function. | |
| 488 | * | |
| 489 | * @param dst the destination map | |
| 490 | * @param src the source map | |
| 491 | * @param clone_func the clone function for the values | |
| 492 | * @param clone_allocator the allocator that is passed to the clone function | |
| 493 | * @param data optional additional data that is passed to the clone function | |
| 494 | * @retval zero when all elements were successfully cloned | |
| 495 | * @retval non-zero when an allocation error occurred | |
| 496 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
497 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
498 | int cxMapClone(CxMap *dst, const CxMap *src, |
| 889 | 499 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); |
| 500 | ||
| 501 | /** | |
| 502 | * Clones entries of a map if their key is not present in another map. | |
| 503 | * | |
| 504 | * @param dst the destination map | |
| 505 | * @param minuend the map to subtract the entries from | |
| 506 | * @param subtrahend the map containing the elements to be subtracted | |
| 507 | * @param clone_func the clone function for the values | |
| 508 | * @param clone_allocator the allocator that is passed to the clone function | |
| 509 | * @param data optional additional data that is passed to the clone function | |
| 510 | * @retval zero when the elements were successfully cloned | |
| 511 | * @retval non-zero when an allocation error occurred | |
| 512 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
513 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
514 | int cxMapDifference(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend, |
| 889 | 515 | 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
|
516 | |
| 889 | 517 | /** |
| 518 | * Clones entries of a map if their key is not present in a list. | |
| 519 | * | |
| 520 | * Note that the list must contain keys of type @c CxKey | |
| 521 | * (or pointers to such keys) and must use @c cx_hash_key_cmp | |
| 522 | * as the compare function. | |
| 523 | * Generic key types cannot be processed in this case. | |
| 524 | * | |
| 525 | * @param dst the destination map | |
| 526 | * @param src the source map | |
| 527 | * @param keys the list of @c CxKey items | |
| 528 | * @param clone_func the clone function for the values | |
| 529 | * @param clone_allocator the allocator that is passed to the clone function | |
| 530 | * @param data optional additional data that is passed to the clone function | |
| 531 | * @retval zero when the elements were successfully cloned | |
| 532 | * @retval non-zero when an allocation error occurred | |
| 533 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
534 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
535 | int cxMapListDifference(CxMap *dst, const CxMap *src, const CxList *keys, |
| 889 | 536 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); |
| 537 | ||
| 538 | ||
| 539 | /** | |
| 540 | * Clones entries of a map only if their key is present in another map. | |
| 541 | * | |
| 542 | * @param dst the destination map | |
| 543 | * @param src the map to clone the entries from | |
| 544 | * @param other the map to check for existence of the keys | |
| 545 | * @param clone_func the clone function for the values | |
| 546 | * @param clone_allocator the allocator that is passed to the clone function | |
| 547 | * @param data optional additional data that is passed to the clone function | |
| 548 | * @retval zero when the elements were successfully cloned | |
| 549 | * @retval non-zero when an allocation error occurred | |
| 550 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
551 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
552 | int cxMapIntersection(CxMap *dst, const CxMap *src, const CxMap *other, |
| 889 | 553 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); |
| 554 | ||
| 555 | /** | |
| 556 | * Clones entries of a map only if their key is present in a list. | |
| 557 | * | |
| 558 | * Note that the list must contain keys of type @c CxKey | |
| 559 | * (or pointers to such keys) and must use @c cx_hash_key_cmp | |
| 560 | * as the compare function. | |
| 561 | * Generic key types cannot be processed in this case. | |
| 562 | * | |
| 563 | * @param dst the destination map | |
| 564 | * @param src the source map | |
| 565 | * @param keys the list of @c CxKey items | |
| 566 | * @param clone_func the clone function for the values | |
| 567 | * @param clone_allocator the allocator that is passed to the clone function | |
| 568 | * @param data optional additional data that is passed to the clone function | |
| 569 | * @retval zero when the elements were successfully cloned | |
| 570 | * @retval non-zero when an allocation error occurred | |
| 571 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
572 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
573 | int cxMapListIntersection(CxMap *dst, const CxMap *src, const CxList *keys, |
| 889 | 574 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); |
| 575 | ||
| 576 | /** | |
| 577 | * Clones entries into a map if their key does not exist yet. | |
| 578 | * | |
| 579 | * If you want to calculate the union of two maps into a fresh new map, | |
| 580 | * you can proceed as follows: | |
| 581 | * 1. Clone the first map into a fresh, empty map. | |
| 582 | * 2. Use this function to clone the second map into the result from step 1. | |
| 583 | * | |
| 584 | * @param dst the destination map | |
| 585 | * @param src the map to clone the entries from | |
| 586 | * @param clone_func the clone function for the values | |
| 587 | * @param clone_allocator the allocator that is passed to the clone function | |
| 588 | * @param data optional additional data that is passed to the clone function | |
| 589 | * @retval zero when the elements were successfully cloned | |
| 590 | * @retval non-zero when an allocation error occurred | |
| 591 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
592 | CX_EXTERN CX_NONNULL_ARG(1, 2, 3) |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
593 | int cxMapUnion(CxMap *dst, const CxMap *src, |
| 889 | 594 | cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); |
| 595 | ||
| 891 | 596 | /** |
| 597 | * Performs a shallow clone of one map into another. | |
| 598 | * | |
| 599 | * This function uses the default allocator, if needed, and performs | |
| 600 | * shallow clones with @c memcpy(). | |
| 601 | * | |
| 602 | * If the destination map already contains entries, the cloned entries | |
| 603 | * are added to that map, possibly overwriting existing elements when | |
| 604 | * the keys already exist. | |
| 605 | * | |
| 606 | * When elements in the destination map need to be replaced, any destructor | |
| 607 | * function is called on the replaced elements before replacing them. | |
| 608 | * | |
| 609 | * @attention If the cloned elements need to be destroyed by a destructor | |
| 610 | * function, you must make sure that the destination map also uses this | |
| 611 | * destructor function. | |
| 612 | * | |
| 613 | * @param dst the destination map | |
| 614 | * @param src the source map | |
| 615 | * @retval zero when all elements were successfully cloned | |
| 616 | * @retval non-zero when an allocation error occurred | |
| 617 | * @see cxMapClone() | |
| 618 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
619 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
620 | int cxMapCloneShallow(CxMap *dst, const CxMap *src); |
| 891 | 621 | |
| 622 | /** | |
| 623 | * Clones entries of a map if their key is not present in another map. | |
| 624 | * | |
| 625 | * This function uses the default allocator, if needed, and performs | |
| 626 | * shallow clones with @c memcpy(). | |
| 627 | * | |
| 628 | * @param dst the destination map | |
| 629 | * @param minuend the map to subtract the entries from | |
| 630 | * @param subtrahend the map containing the elements to be subtracted | |
| 631 | * @retval zero when the elements were successfully cloned | |
| 632 | * @retval non-zero when an allocation error occurred | |
| 633 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
634 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
635 | int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend); |
| 891 | 636 | |
| 637 | /** | |
| 638 | * Clones entries of a map if their key is not present in a list. | |
| 639 | * | |
| 640 | * This function uses the default allocator, if needed, and performs | |
| 641 | * shallow clones with @c memcpy(). | |
| 642 | * | |
| 643 | * Note that the list must contain keys of type @c CxKey | |
| 644 | * (or pointers to such keys) and must use @c cx_hash_key_cmp | |
| 645 | * as the compare function. | |
| 646 | * Generic key types cannot be processed in this case. | |
| 647 | * | |
| 648 | * @param dst the destination map | |
| 649 | * @param src the source map | |
| 650 | * @param keys the list of @c CxKey items | |
| 651 | * @retval zero when the elements were successfully cloned | |
| 652 | * @retval non-zero when an allocation error occurred | |
| 653 | * @see cxMapListDifference() | |
| 654 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
655 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
656 | int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys); |
| 891 | 657 | |
| 658 | /** | |
| 659 | * Clones entries of a map only if their key is present in another map. | |
| 660 | * | |
| 661 | * This function uses the default allocator, if needed, and performs | |
| 662 | * shallow clones with @c memcpy(). | |
| 663 | * | |
| 664 | * @param dst the destination map | |
| 665 | * @param src the map to clone the entries from | |
| 666 | * @param other the map to check for existence of the keys | |
| 667 | * @retval zero when the elements were successfully cloned | |
| 668 | * @retval non-zero when an allocation error occurred | |
| 669 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
670 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
671 | int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other); |
| 891 | 672 | |
| 673 | /** | |
| 674 | * Clones entries of a map only if their key is present in a list. | |
| 675 | * | |
| 676 | * This function uses the default allocator, if needed, and performs | |
| 677 | * shallow clones with @c memcpy(). | |
| 678 | * | |
| 679 | * Note that the list must contain keys of type @c CxKey | |
| 680 | * (or pointers to such keys) and must use @c cx_hash_key_cmp | |
| 681 | * as the compare function. | |
| 682 | * Generic key types cannot be processed in this case. | |
| 683 | * | |
| 684 | * @param dst the destination map | |
| 685 | * @param src the source map | |
| 686 | * @param keys the list of @c CxKey items | |
| 687 | * @retval zero when the elements were successfully cloned | |
| 688 | * @retval non-zero when an allocation error occurred | |
| 689 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
690 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
691 | int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys); |
| 891 | 692 | |
| 693 | /** | |
| 694 | * Clones entries into a map if their key does not exist yet. | |
| 695 | * | |
| 696 | * This function uses the default allocator, if needed, and performs | |
| 697 | * shallow clones with @c memcpy(). | |
| 698 | * | |
| 699 | * If you want to calculate the union of two maps into a fresh new map, | |
| 700 | * you can proceed as follows: | |
| 701 | * 1. Clone the first map into a fresh, empty map. | |
| 702 | * 2. Use this function to clone the second map into the result from step 1. | |
| 703 | * | |
| 704 | * @param dst the destination map | |
| 705 | * @param src the map to clone the entries from | |
| 706 | * @retval zero when the elements were successfully cloned | |
| 707 | * @retval non-zero when an allocation error occurred | |
| 708 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
709 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
710 | int cxMapUnionShallow(CxMap *dst, const CxMap *src); |
| 891 | 711 | |
| 712 | /** | |
| 713 | * Compares the entries of two maps. | |
| 714 | * | |
| 715 | * @param map the map | |
| 716 | * @param other the other map that the first map is compared to | |
| 717 | * @retval zero when both maps have the same key sets | |
| 718 | * and the values are pairwise equivalent | |
| 719 | * @retval negative when the first @p map has fewer keys than the @p other map | |
| 720 | * @retval positive when the first @p map has more keys than the @p other map | |
| 721 | * @retval non-zero (unspecified whether positive or negative) when the size | |
| 722 | * of both maps is equal but a key or a value is different | |
| 723 | */ | |
|
894
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
724 | CX_EXTERN CX_NONNULL |
|
e86049631677
update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
891
diff
changeset
|
725 | int cxMapCompare(const CxMap *map, const CxMap *other); |
|
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
726 | |
|
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
727 | #endif // UCX_MAP_H |