SimGrid: Sets basic usage

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Sets basic usage
Set: generic set datatype

## Functions
void | xbt_set_add (xbt_set_t set, xbt_set_elm_t elm, void_f_pvoid_t free_func)
| Add an element to a set.
void | xbt_set_remove (xbt_set_t set, xbt_set_elm_t elm)
| Remove an element from a set.
void | xbt_set_remove_by_name (xbt_set_t set, const char *key)
| Remove an element from a set providing its name.
xbt_set_elm_t | xbt_set_get_by_name_or_null (xbt_set_t set, const char *key)
| Retrieve data by providing its name.
void | xbt_set_remove_by_name_ext (xbt_set_t set, const char *key, int key_len)
| Remove an element from a set providing its name and the length of the name.
void | xbt_set_remove_by_id (xbt_set_t set, int id)
| Remove an element from a set providing its id.
xbt_set_elm_t | xbt_set_get_by_name (xbt_set_t set, const char *key)
| Retrieve data by providing its name.
xbt_set_elm_t | xbt_set_get_by_name_ext (xbt_set_t set, const char *key, int key_len)
| Retrieve data by providing its name and the length of the name.
xbt_set_elm_t | xbt_set_get_by_id (xbt_set_t set, int id)
| Retrieve data by providing its ID.
unsigned long | xbt_set_length (const xbt_set_t set)
| Returns the number of elements in the set.

## Detailed Description

## Function Documentation

void xbt_set_add | ( | xbt_set_t | set,
|  | xbt_set_elm_t | elm,
|  | void_f_pvoid_t | free_func
| ) |  |

Add an element to a set.

Parameters

  set | set to populate
  elm | element to add.
  free_func | how to free the data

elm->name must be set; if elm->name_len <= 0, it is recomputed. If >0, it's used as is; elm->ID is attributed automatically.

void xbt_set_remove | ( | xbt_set_t | set,
|  | xbt_set_elm_t | elm
| ) |  |

Remove an element from a set.

Parameters

  set | a set
  elm | element to remove

void xbt_set_remove_by_name | ( | xbt_set_t | set,
|  | const char * | key
| ) |  |

Remove an element from a set providing its name.

Parameters

  set | a set
  key | name of the element to remove

xbt_set_elm_t xbt_set_get_by_name_or_null | ( | xbt_set_t | set,
|  | const char * | name
| ) |  |

Retrieve data by providing its name.

Parameters

  set |
  name | Name of the searched cell

Returns
  the data you're looking for, returns NULL if not found

void xbt_set_remove_by_name_ext | ( | xbt_set_t | set,
|  | const char * | key,
|  | int | key_len
| ) |  |

Remove an element from a set providing its name and the length of the name.

Parameters

  set | a set
  key | name of the element to remove
  key_len | length of name

void xbt_set_remove_by_id | ( | xbt_set_t | set,
|  | int | id
| ) |  |

Remove an element from a set providing its id.

Parameters

  set | a set
  id | id of the element to remove

xbt_set_elm_t xbt_set_get_by_name | ( | xbt_set_t | set,
|  | const char * | name
| ) |  |

Retrieve data by providing its name.

Parameters

  set |
  name | Name of the searched cell

Returns
  the data you're looking for

xbt_set_elm_t xbt_set_get_by_name_ext | ( | xbt_set_t | set,
|  | const char * | name,
|  | int | name_len
| ) |  |

Retrieve data by providing its name and the length of the name.

Parameters

  set |
  name | Name of the searched cell
  name_len | length of the name, when strlen cannot be trusted

Returns
  the data you're looking for

This is useful when strlen cannot be trusted because you don't use a char* as name, you weirdo.

xbt_set_elm_t xbt_set_get_by_id | ( | xbt_set_t | set,
|  | int | id
| ) |  |

Retrieve data by providing its ID.

Parameters

  set |
  id | what you're looking for

Returns
  the data you're looking for

Warning
  , if the ID does not exists, you're getting into trouble

unsigned long xbt_set_length | ( | const xbt_set_t | set | ) |

Returns the number of elements in the set.

Parameters

  set | a set

Returns
  the number of elements in the set