src/ucx/map.h

Thu, 19 Dec 2019 19:58:41 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 19 Dec 2019 19:58:41 +0100
changeset 374
be77fb2da242
parent 327
fbc33813265b
permissions
-rw-r--r--

adds set operations for UcxMap

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

mercurial