SimGrid
3.9.90
Versatile Simulation of Distributed Systems
|
Functions | |
xbt_fifo_item_t | xbt_fifo_push (xbt_fifo_t, void *) |
void * | xbt_fifo_pop (xbt_fifo_t) |
xbt_fifo_item_t | xbt_fifo_unshift (xbt_fifo_t, void *) |
void * | xbt_fifo_shift (xbt_fifo_t) |
int | xbt_fifo_size (xbt_fifo_t) |
int | xbt_fifo_is_in (xbt_fifo_t, void *) |
xbt_fifo_item_t | xbt_fifo_search_item (xbt_fifo_t f, int_f_pvoid_pvoid_t cmp_fun, void *closure) |
Search the given element in the fifo using a comparison function. More... | |
xbt_fifo_item_t xbt_fifo_push | ( | xbt_fifo_t | l, |
void * | t | ||
) |
Push
l | list |
t | element |
Add an object at the tail of the list
void* xbt_fifo_pop | ( | xbt_fifo_t | l) |
Pop
l | list |
Removes and returns the object stored at the tail of the list. Returns NULL if the list is empty.
xbt_fifo_item_t xbt_fifo_unshift | ( | xbt_fifo_t | l, |
void * | t | ||
) |
l | list |
t | element |
Add an object at the head of the list
void* xbt_fifo_shift | ( | xbt_fifo_t | l) |
Shift
l | list |
Removes and returns the object stored at the head of the list. Returns NULL if the list is empty.
int xbt_fifo_size | ( | xbt_fifo_t | f) |
f | a list |
int xbt_fifo_is_in | ( | xbt_fifo_t | f, |
void * | content | ||
) |
f | a list |
content | an object |
xbt_fifo_item_t xbt_fifo_search_item | ( | xbt_fifo_t | f, |
int_f_pvoid_pvoid_t | cmp_fun, | ||
void * | closure | ||
) |
Search the given element in the fifo using a comparison function.
This function allows to search an item with a user provided function instead of the pointer comparison used elsewhere in this module. Assume for example that you have a fifo of strings. You cannot use xbt_fifo_remove() to remove, say, "TOTO" from it because internally, xbt_fifo_remove() will do something like "if (item->content == "toto"), then remove it". And the pointer to the item content and the pointer to "toto" will never match. As a solution, the current function provides a way to search elements that are semanticaly equivalent instead of only syntaxically. So, removing "Toto" from a fifo can be achieved this way:
int my_comparison_function(void *searched, void *seen) { return !strcmp(searched, seen); } xbt_fifo_remove_item(fifo, xbt_fifo_search_item(fifo, my_comparison_function, "Toto"));
f | a fifo list |
cmp_fun | the comparison function. Prototype: void *a,void *b -> int. Semantic: returns true iff a=b |
closure | the element to search. It will be provided as first argument to each call of cmp_fun |