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