ucx/cx/map.h

Tue, 21 Oct 2025 16:20:51 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 21 Oct 2025 16:20:51 +0200
changeset 870
e167cf006213
parent 845
f3ab28ed22e5
child 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
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #ifdef __cplusplus
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 extern "C" {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 #endif
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 /** Type for the UCX map. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 typedef struct cx_map_s CxMap;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 /** Type for a map entry. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 typedef struct cx_map_entry_s CxMapEntry;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
54 /** 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
55 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
56
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 /** Type for map class definitions. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 typedef struct cx_map_class_s cx_map_class;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 /** Structure for the UCX map. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 struct cx_map_s {
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
62 /**
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
63 * Base attributes.
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
64 */
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
65 CX_COLLECTION_BASE;
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 /** The map class definition. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 cx_map_class *cl;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 };
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
71 * 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
72 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
73 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
74 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
75 * 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
76 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
77 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
78 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
79 * 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
80 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
81 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
82 };
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 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 * The type of iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 enum cx_map_iterator_type {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 * Iterates over key/value pairs.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 CX_MAP_ITERATOR_PAIRS,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 * Iterates over keys only.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 CX_MAP_ITERATOR_KEYS,
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 * Iterates over values only.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 CX_MAP_ITERATOR_VALUES
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 };
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 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
103 * 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
104 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
105 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
106 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
107 * 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
108 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
109 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
110
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 * 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
113 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
114 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
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 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
118 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
119 * @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
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 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
122
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 * 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
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 * 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
127 * 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
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 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
132 * 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
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 * (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
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 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
137
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 * 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
140 * 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
141 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
142 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
145 * 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
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 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
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 * 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
151 * 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
152 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
153 * @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
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 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
156
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 * 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
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 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
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 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 * The class definition for arbitrary maps.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 struct cx_map_class_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 * Deallocates the entire memory.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
170 void (*deallocate)(struct cx_map_s *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171
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 * Removes all elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 void (*clear)(struct cx_map_s *map);
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 * Add or overwrite an element.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
179 * If the @p value is @c NULL, the implementation
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
180 * shall only allocate memory instead of adding an existing value to the map.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
181 * Returns a pointer to the allocated memory or @c NULL if allocation fails.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
183 void *(*put)(CxMap *map, CxHashKey key, void *value);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 * Returns an element.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
188 void *(*get)(const CxMap *map, CxHashKey key);
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 * Removes an element.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
192 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
193 * 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
194 * to the buffer without invoking any destructor.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
195 * When @p targetbuf is not set, the destructors SHALL be invoked.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
196 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
197 * 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
198 * non-zero, otherwise.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
200 int (*remove)(CxMap *map, CxHashKey key, void *targetbuf);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 * Creates an iterator for this map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
205 CxMapIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type);
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
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
208 /**
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
209 * A shared instance of an empty map.
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
210 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
211 * Writing to that map is not allowed.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
212 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
213 * 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
214 * 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
215 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
216 CX_EXPORT extern CxMap *const cxEmptyMap;
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 * Deallocates the memory of the specified map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
221 * Also calls the content destructor functions for each element, if specified.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
222 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
223 * @param map the map to be freed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
225 CX_EXPORT void cxMapFree(CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 * Clears a map by removing all elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
231 * Also calls the content destructor functions for each element, if specified.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
232 *
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 * @param map the map to be cleared
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
235 cx_attr_nonnull
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
236 CX_EXPORT void cxMapClear(CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
238 /**
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
239 * Returns the number of elements in this map.
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
240 *
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
241 * @param map the map
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
242 * @return the number of stored elements
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
243 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
244 cx_attr_nonnull
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
245 CX_EXPORT size_t cxMapSize(const CxMap *map);
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
246
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 * Creates a value iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 *
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
250 * 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
251 * 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
252 * 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
253 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
254 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * 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
256 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
257 * @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
258 * @return an iterator for the currently stored values
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
260 cx_attr_nodiscard
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
261 CX_EXPORT CxMapIterator cxMapIteratorValues(const CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 * Creates a key iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
266 * 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
267 * during iterator shall be treated as @c const @c CxHashKey* .
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
269 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 * 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
271 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
272 * @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
273 * @return an iterator for the currently stored keys
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
275 cx_attr_nodiscard
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
276 CX_EXPORT CxMapIterator cxMapIteratorKeys(const CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 * Creates an iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
281 * 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
282 * during iterator shall be treated as @c const @c CxMapEntry* .
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
284 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 * 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
286 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
287 * @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
288 * @return an iterator for the currently stored entries
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 * @see cxMapIteratorKeys()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 * @see cxMapIteratorValues()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
292 cx_attr_nodiscard
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
293 CX_EXPORT CxMapIterator cxMapIterator(const CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
296 * Puts a key/value-pair into the map.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
297 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
298 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
299 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
300 * the overwritten element.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
301 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
302 * 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
303 * 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
304 * memcpy().
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
305 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
306 * The @p key is always copied.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
307 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
308 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
309 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
310 * @param value the value
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
311 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
312 * @retval non-zero value on memory allocation failure
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
313 * @see cxMapPut()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
315 cx_attr_nonnull
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
316 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
317
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 * Puts a key/value-pair into the map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
321 * 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
322 * 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
323 * the overwritten element.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
324 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
325 * 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
326 * 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
327 * memcpy().
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
328 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
329 * The @p key is always copied.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
330 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
331 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
332 * @param key (any supported key type) the key
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
333 * @param value (@c void*) the value
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
334 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
335 * @retval non-zero value on memory allocation failure
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
336 * @see CX_HASH_KEY()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
338 #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
339
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
340 /**
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
341 * 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
342 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
343 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
344 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
345 * the overwritten element.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
346 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
347 * 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
348 * meaning a pointer to that pointer.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
349 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
350 * The @p key is always copied.
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 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
353 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
354 * @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
355 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
356 * @retval non-zero value on memory allocation failure
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
357 * @see cxMapEmplace()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
358 */
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
359 cx_attr_nonnull
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
360 CX_EXPORT void *cx_map_emplace(CxMap *map, CxHashKey key);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
363 * 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
364 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
365 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
366 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
367 * the overwritten element.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
368 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
369 * 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
370 * meaning a pointer to that pointer.
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 * The @p key is always copied.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
373 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
374 * @param map (@c CxMap*) the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
375 * @param key (any supported key type) the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
376 * @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
377 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
378 * @retval non-zero value on memory allocation failure
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
379 * @see CX_HASH_KEY()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
380 */
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
381 #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
382
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 * Retrieves a value by using a key.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
385 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
386 * If this map is storing pointers, the stored pointer is returned.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
387 * Otherwise, a pointer to the element within the map's memory
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
388 * 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
389 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
390 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
391 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
392 * @return the value
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
393 * @see cxMapGet()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
395 cx_attr_nonnull cx_attr_nodiscard
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
396 CX_EXPORT void *cx_map_get(const CxMap *map, CxHashKey key);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397
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 * Retrieves a value by using a key.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
401 * If this map is storing pointers, the stored pointer is returned.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
402 * Otherwise, a pointer to the element within the map's memory
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
403 * 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
404 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
405 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
406 * @param key (any supported key type) the key
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
407 * @return (@c void*) the value
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
408 * @see CX_HASH_KEY()
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
409 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
410 #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
411
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 * Removes a key/value-pair from the map by using the key.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
415 * 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
416 * @p targetbuf is @c NULL.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
418 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
419 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
420 * @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
421 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
422 * @retval non-zero the key was not found
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
423 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
424 * @see cxMapRemove()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 * @see cxMapRemoveAndGet()
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 cx_attr_nonnull_arg(1)
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
428 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
429
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
431 * 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
432 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
433 * Always invokes the destructor functions, if any, on the removed element.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
434 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
435 * @param map (@c CxMap*) the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
436 * @param key (any supported key type) the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
437 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
438 * @retval non-zero the key was not found
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
439 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
440 * @see cxMapRemoveAndGet()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
441 * @see CX_HASH_KEY()
174
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 #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
444
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 * Removes a key/value-pair from the map by using the key.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
448 * 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
449 * 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
450 * to hold the element (the map's element size).
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
451 * The destructor functions, if any, will @em not be called.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
453 * 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
454 * and not the object it points to.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
456 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
457 * @param key (any supported key type) the key
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
458 * @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
459 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
460 * @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
461 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
462 * @see cxMapRemove()
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
463 * @see CX_HASH_KEY()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
465 #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
466
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
467 #ifdef __cplusplus
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
468 } // extern "C"
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
469 #endif
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 #endif // UCX_MAP_H

mercurial