Sun, 08 Aug 2021 12:45:31 +0200
implement secretstore unlock command
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
c1bc13faadaa
updates ucx to version 1.0
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 |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | * @file map.h |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | * Hash map implementation. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | * This implementation uses murmur hash 2 and separate chaining with linked |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | * lists. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | * @author Mike Becker |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | * @author Olaf Wintermann |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | #ifndef UCX_MAP_H |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | #define UCX_MAP_H |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | #include "ucx.h" |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | #include "string.h" |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | #include "allocator.h" |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | #include <stdio.h> |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | #ifdef __cplusplus |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | extern "C" { |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | #endif |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | * Loop statement for UCX maps. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | * The <code>key</code> variable is implicitly defined, but the |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | * <code>value</code> variable must be already declared as type information |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | * cannot be inferred. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | * @param key the variable name for the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | * @param value the variable name for the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | * @param iter a UcxMapIterator |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | * @see ucx_map_iterator() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | #define UCX_MAP_FOREACH(key,value,iter) \ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | for(UcxKey key;ucx_map_iter_next(&iter,&key, (void**)&value);) |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | /** Type for the UCX map. @see UcxMap */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | typedef struct UcxMap UcxMap; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | /** Type for a key of a UcxMap. @see UcxKey */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | typedef struct UcxKey UcxKey; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | /** Type for an element of a UcxMap. @see UcxMapElement */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | typedef struct UcxMapElement UcxMapElement; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | /** Type for an iterator over a UcxMap. @see UcxMapIterator */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | typedef struct UcxMapIterator UcxMapIterator; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | /** Structure for the UCX map. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | struct UcxMap { |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | /** An allocator that is used for the map elements. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | UcxAllocator *allocator; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | /** The array of map element lists. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | UcxMapElement **map; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | /** The size of the map is the length of the element list array. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | size_t size; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | /** The count of elements currently stored in this map. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | size_t count; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | }; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | |
505 | 92 | /** Structure to publicly denote a key of a UcxMap. */ |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | struct UcxKey { |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | /** The key data. */ |
505 | 95 | const void *data; |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | /** The length of the key data. */ |
505 | 97 | size_t len; |
98 | /** A cache for the hash value of the key data. */ | |
99 | int hash; | |
100 | }; | |
101 | ||
102 | /** Internal structure for a key of a UcxMap. */ | |
103 | struct UcxMapKey { | |
104 | /** The key data. */ | |
105 | void *data; | |
106 | /** The length of the key data. */ | |
107 | size_t len; | |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | /** The hash value of the key data. */ |
505 | 109 | int hash; |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | }; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | /** Structure for an element of a UcxMap. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | struct UcxMapElement { |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | /** The value data. */ |
505 | 115 | void *data; |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | /** A pointer to the next element in the current list. */ |
505 | 118 | UcxMapElement *next; |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | /** The corresponding key. */ |
505 | 121 | struct UcxMapKey key; |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | }; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | /** Structure for an iterator over a UcxMap. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | struct UcxMapIterator { |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | /** The map to iterate over. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | UcxMap *map; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | /** The current map element. */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | UcxMapElement *cur; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | * The current index of the element list array. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | * <b>Attention: </b> this is <b>NOT</b> the element index! Do <b>NOT</b> |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | * manually iterate over the map by increasing this index. Use |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | * ucx_map_iter_next(). |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | * @see UcxMap.map*/ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | size_t index; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | }; |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | * Creates a new hash map with the specified size. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | * @param size the size of the hash map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | * @return a pointer to the new hash map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | UcxMap *ucx_map_new(size_t size); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | * Creates a new hash map with the specified size using a UcxAllocator. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | * @param allocator the allocator to use |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | * @param size the size of the hash map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | * @return a pointer to the new hash map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | UcxMap *ucx_map_new_a(UcxAllocator *allocator, size_t size); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | * Frees a hash map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | * <b>Note:</b> the contents are <b>not</b> freed, use ucx_map_free_content() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | * before calling this function to achieve that. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | * @param map the map to be freed |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | * @see ucx_map_free_content() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | void ucx_map_free(UcxMap *map); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | * Frees the contents of a hash map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | * This is a convenience function that iterates over the map and passes all |
505 | 171 | * values to the specified destructor function. |
172 | * | |
173 | * If no destructor is specified (<code>NULL</code>), the free() function of | |
174 | * the map's own allocator is used. | |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | * You must ensure, that it is valid to pass each value in the map to the same |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | * destructor function. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | * You should free or clear the map afterwards, as the contents will be invalid. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | * @param map for which the contents shall be freed |
505 | 182 | * @param destr optional pointer to a destructor function |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | * @see ucx_map_free() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | * @see ucx_map_clear() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | void ucx_map_free_content(UcxMap *map, ucx_destructor destr); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | * Clears a hash map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | * <b>Note:</b> the contents are <b>not</b> freed, use ucx_map_free_content() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | * before calling this function to achieve that. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | * @param map the map to be cleared |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | * @see ucx_map_free_content() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | void ucx_map_clear(UcxMap *map); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | * Copies contents from a map to another map using a copy function. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | * <b>Note:</b> The destination map does not need to be empty. However, if it |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | * contains data with keys that are also present in the source map, the contents |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | * are overwritten. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | * @param from the source map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | * @param to the destination map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | * @param fnc the copy function or <code>NULL</code> if the pointer address |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | * shall be copied |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | * @param data additional data for the copy function |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | * @return 0 on success or a non-zero value on memory allocation errors |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | int ucx_map_copy(UcxMap *from, UcxMap *to, copy_func fnc, void *data); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | * Clones the map and rehashes if necessary. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | * <b>Note:</b> In contrast to ucx_map_rehash() the load factor is irrelevant. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | * This function <i>always</i> ensures a new UcxMap.size of at least |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | * 2.5*UcxMap.count. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
223 | * @param map the map to clone |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | * @param fnc the copy function to use or <code>NULL</code> if the new and |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | * the old map shall share the data pointers |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | * @param data additional data for the copy function |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | * @return the cloned map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | * @see ucx_map_copy() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
229 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | UcxMap *ucx_map_clone(UcxMap *map, copy_func fnc, void *data); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
233 | * Increases size of the hash map, if necessary. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | * The load value is 0.75*UcxMap.size. If the element count exceeds the load |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | * value, the map needs to be rehashed. Otherwise no action is performed and |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
237 | * this function simply returns 0. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
239 | * The rehashing process ensures, that the UcxMap.size is at least |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | * 2.5*UcxMap.count. So there is enough room for additional elements without |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
241 | * the need of another soon rehashing. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
242 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | * You can use this function to dramatically increase access performance. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
244 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
245 | * @param map the map to rehash |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
246 | * @return 1, if a memory allocation error occurred, 0 otherwise |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
247 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | int ucx_map_rehash(UcxMap *map); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | * Puts a key/value-pair into the map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
252 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
254 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
255 | * @param value the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
256 | * @return 0 on success, non-zero value on failure |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
257 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
258 | int ucx_map_put(UcxMap *map, UcxKey key, void *value); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
259 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
260 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
261 | * Retrieves a value by using a key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
262 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
263 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
264 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
265 | * @return the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
266 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
267 | void* ucx_map_get(UcxMap *map, UcxKey key); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
268 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
269 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
270 | * Removes a key/value-pair from the map by using the key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
271 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
272 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
273 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
274 | * @return the removed value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
276 | void* ucx_map_remove(UcxMap *map, UcxKey key); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
279 | * Shorthand for putting data with a sstr_t key into the map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
280 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
281 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
282 | * @param value the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
283 | * @return 0 on success, non-zero value on failure |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | * @see ucx_map_put() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
285 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
286 | #define ucx_map_sstr_put(map, key, value) \ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
287 | ucx_map_put(map, ucx_key(key.ptr, key.length), (void*)value) |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
288 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
289 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
290 | * Shorthand for putting data with a C string key into the map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
291 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
292 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
293 | * @param value the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
294 | * @return 0 on success, non-zero value on failure |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | * @see ucx_map_put() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
297 | #define ucx_map_cstr_put(map, key, value) \ |
505 | 298 | ucx_map_put(map, ucx_key(key, strlen(key)), (void*)value) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
299 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
300 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | * Shorthand for putting data with an integer key into the map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
302 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
303 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
304 | * @param value the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
305 | * @return 0 on success, non-zero value on failure |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
306 | * @see ucx_map_put() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
307 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
308 | #define ucx_map_int_put(map, key, value) \ |
505 | 309 | ucx_map_put(map, ucx_key(&key, sizeof(key)), (void*)value) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
310 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
311 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
312 | * Shorthand for getting data from the map with a sstr_t key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
313 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
314 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
315 | * @return the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
316 | * @see ucx_map_get() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
317 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
318 | #define ucx_map_sstr_get(map, key) \ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
319 | ucx_map_get(map, ucx_key(key.ptr, key.length)) |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
321 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
322 | * Shorthand for getting data from the map with a C string key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
323 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
325 | * @return the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
326 | * @see ucx_map_get() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
327 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
328 | #define ucx_map_cstr_get(map, key) \ |
505 | 329 | ucx_map_get(map, ucx_key(key, strlen(key))) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
330 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
331 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
332 | * Shorthand for getting data from the map with an integer key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
333 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
334 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
335 | * @return the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
336 | * @see ucx_map_get() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
337 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
338 | #define ucx_map_int_get(map, key) \ |
505 | 339 | ucx_map_get(map, ucx_key(&key, sizeof(int))) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
340 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
342 | * Shorthand for removing data from the map with a sstr_t key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
343 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
344 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | * @return the removed value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | * @see ucx_map_remove() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
347 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | #define ucx_map_sstr_remove(map, key) \ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | ucx_map_remove(map, ucx_key(key.ptr, key.length)) |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
351 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
352 | * Shorthand for removing data from the map with a C string key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
353 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
354 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | * @return the removed value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
356 | * @see ucx_map_remove() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
357 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | #define ucx_map_cstr_remove(map, key) \ |
505 | 359 | ucx_map_remove(map, ucx_key(key, strlen(key))) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
362 | * Shorthand for removing data from the map with an integer key. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
363 | * @param map the map |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
364 | * @param key the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
365 | * @return the removed value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
366 | * @see ucx_map_remove() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
367 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
368 | #define ucx_map_int_remove(map, key) \ |
505 | 369 | ucx_map_remove(map, ucx_key(&key, sizeof(key))) |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
370 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
371 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
372 | * Creates a UcxKey based on the given data. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
373 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
374 | * This function implicitly computes the hash. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
375 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
376 | * @param data the data for the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
377 | * @param len the length of the data |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
378 | * @return a UcxKey with implicitly computed hash |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
379 | * @see ucx_hash() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
380 | */ |
505 | 381 | UcxKey ucx_key(const void *data, size_t len); |
335
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
382 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
383 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
384 | * Computes a murmur hash-2. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
385 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
386 | * @param data the data to hash |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
387 | * @param len the length of the data |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
388 | * @return the murmur hash-2 of the data |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
389 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
390 | int ucx_hash(const char *data, size_t len); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
391 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
392 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
393 | * Creates an iterator for a map. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
394 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
395 | * <b>Note:</b> A UcxMapIterator iterates over all elements in all element |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | * lists successively. Therefore the order highly depends on the key hashes and |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
397 | * may vary under different map sizes. So generally you may <b>NOT</b> rely on |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
398 | * the iteration order. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
399 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
400 | * <b>Note:</b> The iterator is <b>NOT</b> initialized. You need to call |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
401 | * ucx_map_iter_next() at least once before accessing any information. However, |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
402 | * it is not recommended to access the fields of a UcxMapIterator directly. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
403 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
404 | * @param map the map to create the iterator for |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
405 | * @return an iterator initialized on the first element of the |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
406 | * first element list |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
407 | * @see ucx_map_iter_next() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
408 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
409 | UcxMapIterator ucx_map_iterator(UcxMap *map); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
410 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
411 | /** |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
412 | * Proceeds to the next element of the map (if any). |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
413 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
414 | * Subsequent calls on the same iterator proceed to the next element and |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
415 | * store the key/value-pair into the memory specified as arguments of this |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
416 | * function. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
417 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
418 | * If no further elements are found, this function returns zero and leaves the |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
419 | * last found key/value-pair in memory. |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
420 | * |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
421 | * @param iterator the iterator to use |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
422 | * @param key a pointer to the memory where to store the key |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
423 | * @param value a pointer to the memory where to store the value |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
424 | * @return 1, if another element was found, 0 if all elements has been processed |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
425 | * @see ucx_map_iterator() |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
426 | */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
427 | int ucx_map_iter_next(UcxMapIterator *iterator, UcxKey *key, void **value); |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
428 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
429 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
430 | #ifdef __cplusplus |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
431 | } |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
432 | #endif |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
433 | |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
434 | #endif /* UCX_MAP_H */ |
c1bc13faadaa
updates ucx to version 1.0
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
435 |