ucx
UAP Common Extensions
|
Interface for map implementations. More...
Go to the source code of this file.
Data Structures | |
struct | cx_map_s |
Structure for the UCX map. More... | |
struct | cx_map_class_s |
The class definition for arbitrary maps. More... | |
struct | cx_map_entry_s |
A map entry. More... | |
Macros | |
#define | cxMapPut(map, key, value) |
Puts a key/value-pair into the map. | |
#define | cxMapGet(map, key) |
Retrieves a value by using a key. | |
#define | cxMapRemove(map, key) |
Removes a key/value-pair from the map by using the key. | |
#define | cxMapDetach(map, key) |
Detaches a key/value-pair from the map by using the key without invoking the destructor. | |
#define | cxMapRemoveAndGet(map, key) |
Removes a key/value-pair from the map by using the key. | |
Typedefs | |
typedef struct cx_map_s | CxMap |
Type for the UCX map. | |
typedef struct cx_map_entry_s | CxMapEntry |
Type for a map entry. | |
typedef struct cx_map_class_s | cx_map_class |
Type for map class definitions. | |
Enumerations | |
enum | cx_map_iterator_type { CX_MAP_ITERATOR_PAIRS , CX_MAP_ITERATOR_KEYS , CX_MAP_ITERATOR_VALUES } |
The type of iterator for a map. More... | |
Functions | |
static void | cxMapStoreObjects (CxMap *map) |
Advises the map to store copies of the objects (default mode of operation). | |
static void | cxMapStorePointers (CxMap *map) |
Advises the map to only store pointers to the objects. | |
static void | cxMapDestroy (CxMap *map) |
Deallocates the memory of the specified map. | |
static void | cxMapClear (CxMap *map) |
Clears a map by removing all elements. | |
static CxIterator | cxMapIteratorValues (CxMap const *map) |
Creates a value iterator for a map. | |
static CxIterator | cxMapIteratorKeys (CxMap const *map) |
Creates a key iterator for a map. | |
static CxIterator | cxMapIterator (CxMap const *map) |
Creates an iterator for a map. | |
CxMutIterator | cxMapMutIteratorValues (CxMap *map) |
Creates a mutating iterator over the values of a map. | |
CxMutIterator | cxMapMutIteratorKeys (CxMap *map) |
Creates a mutating iterator over the keys of a map. | |
CxMutIterator | cxMapMutIterator (CxMap *map) |
Creates a mutating iterator for a map. | |
static int | cx_map_put (CxMap *map, CxHashKey key, void *value) |
Puts a key/value-pair into the map. | |
static int | cx_map_put_cxstr (CxMap *map, cxstring key, void *value) |
Puts a key/value-pair into the map. | |
static int | cx_map_put_mustr (CxMap *map, cxmutstr key, void *value) |
Puts a key/value-pair into the map. | |
static int | cx_map_put_str (CxMap *map, char const *key, void *value) |
Puts a key/value-pair into the map. | |
static void * | cx_map_get (CxMap const *map, CxHashKey key) |
Retrieves a value by using a key. | |
static void * | cx_map_get_cxstr (CxMap const *map, cxstring key) |
Retrieves a value by using a key. | |
static void * | cx_map_get_mustr (CxMap const *map, cxmutstr key) |
Retrieves a value by using a key. | |
static void * | cx_map_get_str (CxMap const *map, char const *key) |
Retrieves a value by using a key. | |
static void | cx_map_remove (CxMap *map, CxHashKey key) |
Removes a key/value-pair from the map by using the key. | |
static void | cx_map_remove_cxstr (CxMap *map, cxstring key) |
Removes a key/value-pair from the map by using the key. | |
static void | cx_map_remove_mustr (CxMap *map, cxmutstr key) |
Removes a key/value-pair from the map by using the key. | |
static void | cx_map_remove_str (CxMap *map, char const *key) |
Removes a key/value-pair from the map by using the key. | |
static void | cx_map_detach (CxMap *map, CxHashKey key) |
Detaches a key/value-pair from the map by using the key without invoking the destructor. | |
static void | cx_map_detach_cxstr (CxMap *map, cxstring key) |
Detaches a key/value-pair from the map by using the key without invoking the destructor. | |
static void | cx_map_detach_mustr (CxMap *map, cxmutstr key) |
Detaches a key/value-pair from the map by using the key without invoking the destructor. | |
static void | cx_map_detach_str (CxMap *map, char const *key) |
Detaches a key/value-pair from the map by using the key without invoking the destructor. | |
static void * | cx_map_remove_and_get (CxMap *map, CxHashKey key) |
Removes a key/value-pair from the map by using the key. | |
static void * | cx_map_remove_and_get_cxstr (CxMap *map, cxstring key) |
Removes a key/value-pair from the map by using the key. | |
static void * | cx_map_remove_and_get_mustr (CxMap *map, cxmutstr key) |
Removes a key/value-pair from the map by using the key. | |
static void * | cx_map_remove_and_get_str (CxMap *map, char const *key) |
Removes a key/value-pair from the map by using the key. | |
Variables | |
CxMap *const | cxEmptyMap |
A shared instance of an empty map. | |
Interface for map implementations.
#define cxMapDetach | ( | map, | |
key | |||
) |
Detaches a key/value-pair from the map by using the key without invoking the destructor.
In general, you should only use this function if the map does not own the data and there is a valid reference to the data somewhere else in the program. In all other cases it is preferable to use cxMapRemove() or cxMapRemoveAndGet().
map | the map |
key | the key |
#define cxMapGet | ( | map, | |
key | |||
) |
Retrieves a value by using a key.
map | the map |
key | the key |
#define cxMapPut | ( | map, | |
key, | |||
value | |||
) |
Puts a key/value-pair into the map.
map | the map |
key | the key |
value | the value |
#define cxMapRemove | ( | map, | |
key | |||
) |
Removes a key/value-pair from the map by using the key.
Always invokes the destructor function, if any, on the removed element. If this map is storing pointers and you just want to retrieve the pointer without invoking the destructor, use cxMapRemoveAndGet(). If you just want to detach the element from the map without invoking the destructor or returning the element, use cxMapDetach().
map | the map |
key | the key |
#define cxMapRemoveAndGet | ( | map, | |
key | |||
) |
Removes a key/value-pair from the map by using the key.
This function can be used when the map is storing pointers, in order to retrieve the pointer from the map without invoking any destructor function. Sometimes you do not want the pointer to be returned - in that case (instead of suppressing the "unused result" warning) you can use cxMapDetach().
If this map is not storing pointers, this function behaves like cxMapRemove() and returns NULL
.
map | the map |
key | the key |
NULL
if either the key is not present in the map or the map is not storing pointers enum cx_map_iterator_type |
Detaches a key/value-pair from the map by using the key without invoking the destructor.
map | the map |
key | the key |
Detaches a key/value-pair from the map by using the key without invoking the destructor.
map | the map |
key | the key |
Detaches a key/value-pair from the map by using the key without invoking the destructor.
map | the map |
key | the key |
|
inlinestatic |
Detaches a key/value-pair from the map by using the key without invoking the destructor.
map | the map |
key | the key |
Retrieves a value by using a key.
map | the map |
key | the key |
Retrieves a value by using a key.
map | the map |
key | the key |
Retrieves a value by using a key.
map | the map |
key | the key |
|
inlinestatic |
Retrieves a value by using a key.
map | the map |
key | the key |
Puts a key/value-pair into the map.
map | the map |
key | the key |
value | the value |
Puts a key/value-pair into the map.
map | the map |
key | the key |
value | the value |
Puts a key/value-pair into the map.
map | the map |
key | the key |
value | the value |
|
inlinestatic |
Puts a key/value-pair into the map.
map | the map |
key | the key |
value | the value |
Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
NULL
if either the key is not present in the map or the map is not storing pointers Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
NULL
if either the key is not present in the map or the map is not storing pointers Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
NULL
if either the key is not present in the map or the map is not storing pointers
|
inlinestatic |
Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
NULL
if either the key is not present in the map or the map is not storing pointers Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
|
inlinestatic |
Removes a key/value-pair from the map by using the key.
map | the map |
key | the key |
|
inlinestatic |
Clears a map by removing all elements.
map | the map to be cleared |
|
inlinestatic |
Deallocates the memory of the specified map.
map | the map to be destroyed |
|
inlinestatic |
Creates an iterator for a map.
The elements of the iterator are key/value pairs of type CxMapEntry.
map | the map to create the iterator for |
|
inlinestatic |
Creates a key iterator for a map.
The elements of the iterator are keys of type CxHashKey.
map | the map to create the iterator for |
|
inlinestatic |
Creates a value iterator for a map.
map | the map to create the iterator for |
CxMutIterator cxMapMutIterator | ( | CxMap * | map | ) |
Creates a mutating iterator for a map.
The elements of the iterator are key/value pairs of type CxMapEntry.
map | the map to create the iterator for |
CxMutIterator cxMapMutIteratorKeys | ( | CxMap * | map | ) |
Creates a mutating iterator over the keys of a map.
The elements of the iterator are keys of type CxHashKey.
map | the map to create the iterator for |
CxMutIterator cxMapMutIteratorValues | ( | CxMap * | map | ) |
Creates a mutating iterator over the values of a map.
map | the map to create the iterator for |
|
inlinestatic |
Advises the map to store copies of the objects (default mode of operation).
Retrieving objects from this map will yield pointers to the copies stored within this list.
map | the map |
|
inlinestatic |
Advises the map to only store pointers to the objects.
Retrieving objects from this list will yield the original pointers stored.
map | the map |
|
extern |
A shared instance of an empty map.
Writing to that map is undefined.