SimGrid  3.14.159
Versatile Simulation of Distributed Systems
Dictionaries with non-nul terminated keys

Detailed Description

Those functions work even with non-null terminated keys.

Classes

struct  s_xbt_dict_cursor
 

Functions

void xbt_dict_set_ext (xbt_dict_t dict, const char *key, int key_len, void *data, void_f_pvoid_t free_ctn)
 Add data to the dict (arbitrary key) More...
 
voidxbt_dict_get_ext (xbt_dict_t dict, const char *key, int key_len)
 Retrieve data from the dict (arbitrary key) More...
 
voidxbt_dict_get_or_null_ext (xbt_dict_t dict, const char *key, int key_len)
 like xbt_dict_get_ext(), but returning nullptr when not found More...
 
void xbt_dict_remove_ext (xbt_dict_t dict, const char *key, int key_len)
 Remove data from the dict (arbitrary key) More...
 

Function Documentation

◆ xbt_dict_set_ext()

void xbt_dict_set_ext ( xbt_dict_t  dict,
const char *  key,
int  key_len,
void data,
void_f_pvoid_t  free_ctn 
)

Add data to the dict (arbitrary key)

Parameters
dictthe container
keythe key to set the new data
key_lenthe size of the key
datathe data to add in the dict
free_ctnfunction to call with (data as argument) when data is removed from the dictionary. This param will only be considered when the dict was instantiated with xbt_dict_new() and not xbt_dict_new_homogeneous()

Set the data in the structure under the key, which can be any kind of data, as long as its length is provided in key_len.

◆ xbt_dict_get_ext()

void* xbt_dict_get_ext ( xbt_dict_t  dict,
const char *  key,
int  key_len 
)

Retrieve data from the dict (arbitrary key)

Parameters
dictthe dealer of data
keythe key to find data
key_lenthe size of the key
Returns
the data that we are looking for

Search the given key. Throws not_found_error when not found.

◆ xbt_dict_get_or_null_ext()

void* xbt_dict_get_or_null_ext ( xbt_dict_t  dict,
const char *  key,
int  key_len 
)

like xbt_dict_get_ext(), but returning nullptr when not found

◆ xbt_dict_remove_ext()

void xbt_dict_remove_ext ( xbt_dict_t  dict,
const char *  key,
int  key_len 
)

Remove data from the dict (arbitrary key)

Parameters
dictthe trash can
keythe key of the data to be removed
key_lenthe size of the key

Remove the entry associated with the given key (throws not_found)