65 #define UCX_MAP_FOREACH(key,value,iter) \ 66 for(UcxKey key;ucx_map_iter_next(&iter,&key, (void**)&value);) 304 #define ucx_map_sstr_put(map, key, value) \ 305 ucx_map_put(map, ucx_key(key.ptr, key.length), (void*)value) 315 #define ucx_map_cstr_put(map, key, value) \ 316 ucx_map_put(map, ucx_key(key, strlen(key)), (void*)value) 326 #define ucx_map_int_put(map, key, value) \ 327 ucx_map_put(map, ucx_key(&key, sizeof(key)), (void*)value) 336 #define ucx_map_sstr_get(map, key) \ 337 ucx_map_get(map, ucx_key(key.ptr, key.length)) 346 #define ucx_map_cstr_get(map, key) \ 347 ucx_map_get(map, ucx_key(key, strlen(key))) 356 #define ucx_map_int_get(map, key) \ 357 ucx_map_get(map, ucx_key(&key, sizeof(int))) 366 #define ucx_map_sstr_remove(map, key) \ 367 ucx_map_remove(map, ucx_key(key.ptr, key.length)) 376 #define ucx_map_cstr_remove(map, key) \ 377 ucx_map_remove(map, ucx_key(key, strlen(key))) 386 #define ucx_map_int_remove(map, key) \ 387 ucx_map_remove(map, ucx_key(&key, sizeof(key))) 408 int ucx_hash(
const char *data,
size_t len);
void *(* copy_func)(const void *, void *)
Function pointer to a copy function.
Definition: ucx.h:106
universe@390:
size_t index
The current index of the element list array.
Definition: map.h:138
universe@390:
size_t len
The length of the key data.
Definition: map.h:107
universe@390:
UcxMap * ucx_map_difference_a(UcxAllocator *allocator, const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the difference of two maps.
Definition: map.c:386
universe@390:
Bounded string implementation.
universe@390:
Main UCX Header providing most common definitions.
universe@390:
int ucx_hash(const char *data, size_t len)
Computes a murmur hash-2.
Definition: map.c:260
universe@390:
int hash
The hash value of the key data.
Definition: map.h:109
universe@390:
void ucx_map_free_content(UcxMap *map, ucx_destructor destr)
Frees the contents of a hash map.
Definition: map.c:85
universe@390:
void * ucx_map_get(UcxMap const *map, UcxKey key)
Retrieves a value by using a key.
Definition: map.c:243
universe@390:
UcxMapIterator ucx_map_iterator(UcxMap const *map)
Creates an iterator for a map.
Definition: map.c:302
universe@390:
UcxMap * ucx_map_union(const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the union of two maps.
Definition: map.c:343
universe@390:
int hash
A cache for the hash value of the key data.
Definition: map.h:99
universe@390:
void ucx_map_clear(UcxMap *map)
Clears a hash map.
Definition: map.c:97
universe@390:
UcxMap * ucx_map_difference(const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the difference of two maps.
Definition: map.c:380
universe@390:
Structure for an element of a UcxMap.
Definition: map.h:113
universe@390:
Structure to publicly denote a key of a UcxMap.
Definition: map.h:93
universe@390:
size_t count
The count of elements currently stored in this map.
Definition: map.h:89
universe@390:
UcxMapElement * next
A pointer to the next element in the current list.
Definition: map.h:118
universe@390:
UcxMap * ucx_map_union_a(UcxAllocator *allocator, const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the union of two maps.
Definition: map.c:349
universe@390:
UcxMap const * map
The map to iterate over.
Definition: map.h:127
universe@390:
Structure for an iterator over a UcxMap.
Definition: map.h:125
universe@390:
void * data
The value data.
Definition: map.h:115
universe@390:
int ucx_map_copy(UcxMap const *from, UcxMap *to, copy_func fnc, void *data)
Copies contents from a map to another map using a copy function.
Definition: map.c:106
universe@390:
UCX allocator data structure containing memory management functions.
Definition: allocator.h:88
universe@390:
UcxKey ucx_key(const void *data, size_t len)
Creates a UcxKey based on the given data.
Definition: map.c:251
universe@390:
UcxMap * ucx_map_new(size_t size)
Creates a new hash map with the specified size.
Definition: map.c:34
universe@390:
UcxMapElement * cur
The current map element.
Definition: map.h:130
universe@390:
UcxMap * ucx_map_new_a(UcxAllocator *allocator, size_t size)
Creates a new hash map with the specified size using a UcxAllocator.
Definition: map.c:38
universe@390:
UcxAllocator * allocator
An allocator that is used for the map elements.
Definition: map.h:83
universe@390:
Internal structure for a key of a UcxMap.
Definition: map.h:103
universe@390:
int ucx_map_put(UcxMap *map, UcxKey key, void *value)
Puts a key/value-pair into the map.
Definition: map.c:158
universe@390:
UcxMap * ucx_map_clone_a(UcxAllocator *allocator, UcxMap const *map, copy_func fnc, void *data)
Clones the map and rehashes if necessary.
Definition: map.c:121
universe@390:
size_t size
The size of the map is the length of the element list array.
Definition: map.h:87
universe@390:
int ucx_map_iter_next(UcxMapIterator *iterator, UcxKey *key, void **value)
Proceeds to the next element of the map (if any).
Definition: map.c:310
universe@390:
const void * data
The key data.
Definition: map.h:95
universe@390:
Allocator for custom memory management.
universe@390:
Structure for the UCX map.
Definition: map.h:81
universe@390:
void * ucx_map_remove(UcxMap *map, UcxKey key)
Removes a key/value-pair from the map by using the key.
Definition: map.c:247
universe@390:
size_t len
The length of the key data.
Definition: map.h:97
universe@390:
UcxMap * ucx_map_intersection(const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the intersection of two maps.
Definition: map.c:357
universe@390:
int ucx_map_rehash(UcxMap *map)
Increases size of the hash map, if necessary.
Definition: map.c:132
universe@390:
void ucx_map_free(UcxMap *map)
Frees a hash map.
Definition: map.c:79
universe@390:
UcxMap * ucx_map_clone(UcxMap const *map, copy_func fnc, void *data)
Clones the map and rehashes if necessary.
Definition: map.c:117
universe@390:
UcxMapElement ** map
The array of map element lists.
Definition: map.h:85
universe@390:
UcxMap * ucx_map_intersection_a(UcxAllocator *allocator, const UcxMap *first, const UcxMap *second, copy_func cpfnc, void *cpdata)
Returns the intersection of two maps.
Definition: map.c:363
universe@390:
void * data
The key data.
Definition: map.h:105
universe@390:
void(* ucx_destructor)(void *)
A function pointer to a destructor function.
Definition: ucx.h:72
universe@390: