ucx/cx/map.h

Wed, 31 Dec 2025 16:40:12 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 31 Dec 2025 16:40:12 +0100
changeset 1040
473d8cb58a6c
parent 1016
ccde46662db7
permissions
-rw-r--r--

update ucx to version 4.0

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 /** Type for the UCX map. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 typedef struct cx_map_s CxMap;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 /** Type for a map entry. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 typedef struct cx_map_entry_s CxMapEntry;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
55 /** 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
56 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
57
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 /** Type for map class definitions. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 typedef struct cx_map_class_s cx_map_class;
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 /** Structure for the UCX map. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 struct cx_map_s {
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
63 /**
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
64 * Base attributes.
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
65 */
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
66 CX_COLLECTION_BASE;
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 /** The map class definition. */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 cx_map_class *cl;
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
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
72 * 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
73 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
74 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
75 /**
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 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
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 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
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 value.
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 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
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
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
85 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 * The type of iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 enum cx_map_iterator_type {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 * Iterates over key/value pairs.
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 CX_MAP_ITERATOR_PAIRS,
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 keys only.
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_KEYS,
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 values 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_VALUES
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
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 /**
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
104 * 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
105 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
106 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
107 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
108 * 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
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 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
113 * 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
114 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
115 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
118 * 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
119 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
120 * @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
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 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
125 * 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
126 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
127 * 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
128 * 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
129 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
130 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
133 * 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
134 *
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
135 * (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
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 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
140 * 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
141 * 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
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 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
146 * 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
147 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
148 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
151 * 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
152 * 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
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 * @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
155 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
156 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
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 /**
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
159 * 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
160 */
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
161 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
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
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
164 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 * The class definition for arbitrary maps.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 struct cx_map_class_s {
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 * Deallocates the entire memory.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 */
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
171 void (*deallocate)(struct cx_map_s *map);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 * Removes all elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 */
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 void (*clear)(struct cx_map_s *map);
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 * Add or overwrite an element.
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
180 * If the @p value is @c NULL, the implementation
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
181 * 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
182 * 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
183 */
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
184 CxMapEntry (*put)(CxMap *map, CxHashKey key, void *value);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 * Returns an element.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
189 void *(*get)(const CxMap *map, CxHashKey key);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 * Removes an element.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
193 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
194 * 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
195 * to the buffer without invoking any destructor.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
196 * When @p targetbuf is not set, the destructors SHALL be invoked.
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 * 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
199 * non-zero, otherwise.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
201 int (*remove)(CxMap *map, CxHashKey key, void *targetbuf);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 * Creates an iterator for this map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 */
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
206 CxMapIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type);
174
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
187
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
209 /**
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
210 * A shared instance of an empty map.
24ce2c326d85 implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
211 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
212 * Writing to that map is not allowed.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
213 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
214 * 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
215 * 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
216 */
870
e167cf006213 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 845
diff changeset
217 CX_EXPORT extern CxMap *const cxEmptyMap;
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 * Deallocates the memory of the specified map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
222 * Also calls the content destructor functions for each element, if specified.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
223 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
224 * @param map the map to be freed
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
226 CX_EXTERN
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
227 void cxMapFree(CxMap *map);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 * Clears a map by removing all elements.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
232 * Also calls the content destructor functions for each element, if specified.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
233 *
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 * @param map the map to be cleared
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
236 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
237 void cxMapClear(CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
239 /**
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
240 * Returns the number of elements in this map.
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
241 *
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
242 * @param map the map
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
243 * @return the number of stored elements
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
244 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
245 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
246 size_t cxMapSize(const CxMap *map);
324
ce13a778654a update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
247
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 * Creates a value iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 *
471
063a9f29098c ucx update + fix doc attach/detach + fix ui_set with unbound values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 440
diff changeset
251 * 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
252 * 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
253 * 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
254 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
255 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 * 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
257 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
258 * @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
259 * @return an iterator for the currently stored values
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
261 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
262 CxMapIterator cxMapIteratorValues(const CxMap *map);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 * Creates a key iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
267 * 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
268 * during iterator shall be treated as @c const @c CxHashKey* .
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
270 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 * 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
272 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
273 * @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
274 * @return an iterator for the currently stored keys
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
276 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
277 CxMapIterator cxMapIteratorKeys(const CxMap *map);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 * Creates an iterator for a map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
282 * 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
283 * during iterator shall be treated as @c const @c CxMapEntry* .
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
285 * @note An iterator iterates over all elements successively. Therefore, the order
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 * 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
287 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
288 * @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
289 * @return an iterator for the currently stored entries
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 * @see cxMapIteratorKeys()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 * @see cxMapIteratorValues()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
293 CX_EXTERN CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
294 CxMapIterator cxMapIterator(const CxMap *map);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
297 * Puts a key/value-pair into the map.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
298 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
299 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
300 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
301 * the overwritten element.
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 * 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
304 * 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
305 * memcpy().
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 * The @p key is always copied.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
308 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
309 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
310 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
311 * @param value the value
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
312 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
313 * @retval non-zero value on memory allocation failure
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
314 * @see cxMapPut()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
316 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
317 int cx_map_put(CxMap *map, CxHashKey key, void *value);
174
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 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 * Puts a key/value-pair into the map.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
322 * 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
323 * 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
324 * the overwritten element.
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
325 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
326 * 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
327 * 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
328 * memcpy().
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 * The @p key is always copied.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
331 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
332 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
333 * @param key (any supported key type) the key
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
334 * @param value (@c void*) the value
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
335 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
336 * @retval non-zero value on memory allocation failure
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
337 * @see CX_HASH_KEY()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
339 #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
340
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
341 /**
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
342 * 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
343 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
344 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
345 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
346 * the overwritten element.
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 * 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
349 * meaning a pointer to that pointer.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
350 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
351 * The @p key is always copied.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
352 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
353 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
354 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
355 * @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
356 * @see cxMapEmplace()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
357 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
358 CX_EXTERN CX_NONNULL CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
359 void *cx_map_emplace(CxMap *map, CxHashKey key);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 /**
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
362 * 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
363 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
364 * A possible existing value will be overwritten.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
365 * If destructor functions are specified, they are called for
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
366 * the overwritten element.
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 * 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
369 * meaning a pointer to that pointer.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
370 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
371 * The @p key is always copied.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
372 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
373 * @param map (@c CxMap*) the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
374 * @param key (any supported key type) the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
375 * @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
376 * @see CX_HASH_KEY()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
377 */
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
378 #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
379
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 * Retrieves a value by using a 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 * If this map is storing pointers, the stored pointer is returned.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
384 * Otherwise, a pointer to the element within the map's memory
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
385 * 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
386 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
387 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
388 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
389 * @return the value
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
390 * @see cxMapGet()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
392 CX_EXTERN CX_NONNULL CX_NODISCARD
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
393 void *cx_map_get(const CxMap *map, CxHashKey key);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 * Retrieves a value by using a key.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
398 * If this map is storing pointers, the stored pointer is returned.
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
399 * Otherwise, a pointer to the element within the map's memory
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
400 * 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
401 *
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
402 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
403 * @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
404 * @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
405 * @see CX_HASH_KEY()
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
406 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
407 #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
408
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 /**
943
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
410 * 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
411 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
412 * @param map (@c CxMap*) the map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
413 * @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
414 * @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
415 * @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
416 * @see CX_HASH_KEY()
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
417 */
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
418 #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
419
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
420 /**
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 * Removes a key/value-pair from the map by using the key.
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
423 * 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
424 * @p targetbuf is @c NULL.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 *
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
426 * @param map the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
427 * @param key the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
428 * @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
429 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
430 * @retval non-zero the key was not found
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
431 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
432 * @see cxMapRemove()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 * @see cxMapRemoveAndGet()
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
435 CX_EXTERN CX_NONNULL_ARG(1)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
436 int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437
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 * 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
440 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
441 * Always invokes the destructor functions, if any, on the removed element.
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
442 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
443 * @param map (@c CxMap*) the map
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
444 * @param key (any supported key type) the key
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
445 * @retval zero success
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
446 * @retval non-zero the key was not found
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
447 *
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
448 * @see cxMapRemoveAndGet()
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
449 * @see CX_HASH_KEY()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
451 #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
452
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 /**
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 * Removes a key/value-pair from the map by using the key.
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 * 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
457 * 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
458 * to hold the element (the map's element size).
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
459 * The destructor functions, if any, will @em not be called.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
461 * 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
462 * and not the object it points to.
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
464 * @param map (@c CxMap*) the map
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
465 * @param key (any supported key type) the key
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
466 * @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
467 * @retval zero success
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
468 * @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
469 *
440
7c4b9cba09ca update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 373
diff changeset
470 * @see cxMapRemove()
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
471 * @see CX_HASH_KEY()
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 */
845
f3ab28ed22e5 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 471
diff changeset
473 #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
474
943
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
475 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
476 * 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
477 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
478 * 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
479 * 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
480 * the keys already exist.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
481 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
482 * 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
483 * 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
484 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
485 * @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
486 * 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
487 * destructor function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
488 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
489 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
490 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
491 * @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
492 * @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
493 * @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
494 * @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
495 * @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
496 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
497 CX_EXTERN CX_NONNULL_ARG(1, 2, 3)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
498 int cxMapClone(CxMap *dst, const CxMap *src,
943
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
499 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
500
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 * 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
503 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
504 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
505 * @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
506 * @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
507 * @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
508 * @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
509 * @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
510 * @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
511 * @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
512 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
513 CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
514 int cxMapDifference(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
515 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
516
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
517 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
518 * 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
519 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
520 * 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
521 * (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
522 * as the compare function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
523 * 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
524 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
525 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
526 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
527 * @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
528 * @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
529 * @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
530 * @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
531 * @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
532 * @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
533 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
534 CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
535 int cxMapListDifference(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
536 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
537
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
538
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 * 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
541 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
542 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
543 * @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
544 * @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
545 * @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
546 * @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
547 * @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
548 * @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
549 * @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
550 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
551 CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
552 int cxMapIntersection(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
553 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
554
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
555 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
556 * 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
557 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
558 * 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
559 * (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
560 * as the compare function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
561 * 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
562 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
563 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
564 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
565 * @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
566 * @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
567 * @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
568 * @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
569 * @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
570 * @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
571 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
572 CX_EXTERN CX_NONNULL_ARG(1, 2, 3, 4)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
573 int cxMapListIntersection(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
574 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
575
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
576 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
577 * 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
578 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
579 * 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
580 * you can proceed as follows:
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
581 * 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
582 * 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
583 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
584 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
585 * @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
586 * @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
587 * @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
588 * @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
589 * @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
590 * @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
591 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
592 CX_EXTERN CX_NONNULL_ARG(1, 2, 3)
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
593 int cxMapUnion(CxMap *dst, const CxMap *src,
943
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
594 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
595
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
596 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
597 * 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
598 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
599 * 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
600 * shallow clones with @c memcpy().
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 * 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
603 * 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
604 * the keys already exist.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
605 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
606 * 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
607 * 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
608 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
609 * @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
610 * 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
611 * destructor function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
612 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
613 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
614 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
615 * @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
616 * @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
617 * @see cxMapClone()
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
618 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
619 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
620 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
621
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
622 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
623 * 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
624 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
625 * 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
626 * shallow clones with @c memcpy().
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 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
629 * @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
630 * @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
631 * @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
632 * @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
633 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
634 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
635 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
636
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
637 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
638 * 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
639 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
640 * 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
641 * shallow clones with @c memcpy().
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 * 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
644 * (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
645 * as the compare function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
646 * 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
647 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
648 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
649 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
650 * @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
651 * @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
652 * @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
653 * @see cxMapListDifference()
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
654 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
655 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
656 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
657
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
658 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
659 * 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
660 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
661 * 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
662 * shallow clones with @c memcpy().
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 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
665 * @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
666 * @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
667 * @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
668 * @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
669 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
670 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
671 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
672
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
673 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
674 * 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
675 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
676 * 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
677 * shallow clones with @c memcpy().
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
678 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
679 * 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
680 * (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
681 * as the compare function.
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
682 * 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
683 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
684 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
685 * @param src the source map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
686 * @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
687 * @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
688 * @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
689 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
690 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
691 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
692
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
693 /**
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
694 * 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
695 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
696 * 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
697 * shallow clones with @c memcpy().
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
698 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
699 * 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
700 * you can proceed as follows:
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
701 * 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
702 * 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
703 *
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
704 * @param dst the destination map
9b5948aa5b90 update ucx to version 3.2
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 870
diff changeset
705 * @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
706 * @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
707 * @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
708 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
709 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
710 int cxMapUnionShallow(CxMap *dst, const CxMap *src);
1016
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
711
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
712 /**
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
713 * Compares the entries of two maps.
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
714 *
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
715 * @param map the map
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
716 * @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
717 * @retval zero when both maps have the same key sets
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
718 * and the values are pairwise equivalent
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
719 * @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
720 * @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
721 * @retval non-zero (unspecified whether positive or negative) when the size
ccde46662db7 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 943
diff changeset
722 * 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
723 */
1040
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
724 CX_EXTERN CX_NONNULL
473d8cb58a6c update ucx to version 4.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 1016
diff changeset
725 int cxMapCompare(const CxMap *map, const CxMap *other);
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
726
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
727 #endif // UCX_MAP_H

mercurial