ucx/cx/map.h

Thu, 18 Dec 2025 17:50:15 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 18 Dec 2025 17:50:15 +0100
changeset 1016
ccde46662db7
parent 943
9b5948aa5b90
permissions
-rw-r--r--

update ucx

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

mercurial