SimGrid  3.13
Versatile Simulation of Distributed Systems
dynar.c File Reference
#include "xbt/misc.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
#include "xbt/ex.h"
#include "xbt/dynar.h"
#include <sys/types.h>

Functions

 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (xbt_dyn, xbt,"Dynamic arrays")
 
static void _sanity_check_dynar (xbt_dynar_t dynar)
 
static void _sanity_check_idx (int idx)
 
static void _check_inbound_idx (xbt_dynar_t dynar, int idx)
 
static void _check_populated_dynar (xbt_dynar_t dynar)
 
static void _xbt_dynar_resize (xbt_dynar_t dynar, unsigned long new_size)
 
static void _xbt_dynar_expand (xbt_dynar_t const dynar, const unsigned long nb)
 
static void_xbt_dynar_elm (const xbt_dynar_t dynar, const unsigned long idx)
 
static void _xbt_dynar_get_elm (void *const dst, const xbt_dynar_t dynar, const unsigned long idx)
 
void xbt_dynar_dump (xbt_dynar_t dynar)
 
xbt_dynar_t xbt_dynar_new (const unsigned long elmsize, void_f_pvoid_t const free_f)
 Constructor. More...
 
void xbt_dynar_free_container (xbt_dynar_t *dynar)
 Destructor of the structure not touching to the content. More...
 
void xbt_dynar_reset (xbt_dynar_t const dynar)
 Frees the content and set the size to 0. More...
 
void xbt_dynar_merge (xbt_dynar_t *d1, xbt_dynar_t *d2)
 Merge dynar d2 into d1. More...
 
void xbt_dynar_shrink (xbt_dynar_t dynar, int empty_slots_wanted)
 Shrink the dynar by removing empty slots at the end of the internal array. More...
 
void xbt_dynar_free (xbt_dynar_t *dynar)
 Destructor. More...
 
void xbt_dynar_free_voidp (void *d)
 free a dynar passed as void* (handy to store dynar in dynars or dict) More...
 
unsigned long xbt_dynar_length (const xbt_dynar_t dynar)
 Count of dynar's elements. More...
 
int xbt_dynar_is_empty (const xbt_dynar_t dynar)
 check if a dynar is empty More...
 
void xbt_dynar_get_cpy (const xbt_dynar_t dynar, const unsigned long idx, void *const dst)
 Retrieve a copy of the Nth element of a dynar. More...
 
voidxbt_dynar_get_ptr (const xbt_dynar_t dynar, const unsigned long idx)
 Retrieve a pointer to the Nth element of a dynar. More...
 
voidxbt_dynar_set_at_ptr (const xbt_dynar_t dynar, const unsigned long idx)
 
void xbt_dynar_set (xbt_dynar_t dynar, const int idx, const void *const src)
 Set the Nth element of a dynar (expanded if needed). More...
 
void xbt_dynar_replace (xbt_dynar_t dynar, const unsigned long idx, const void *const object)
 Set the Nth element of a dynar (expanded if needed). More...
 
voidxbt_dynar_insert_at_ptr (xbt_dynar_t const dynar, const int idx)
 Make room for a new element, and return a pointer to it. More...
 
void xbt_dynar_insert_at (xbt_dynar_t const dynar, const int idx, const void *const src)
 Set the Nth dynar's element, expanding the dynar and sliding the previous values to the right. More...
 
void xbt_dynar_remove_at (xbt_dynar_t const dynar, const int idx, void *const object)
 Remove the Nth dynar's element, sliding the previous values to the left. More...
 
void xbt_dynar_remove_n_at (xbt_dynar_t const dynar, const unsigned int n, const int idx)
 Remove a slice of the dynar, sliding the rest of the values to the left. More...
 
unsigned int xbt_dynar_search (xbt_dynar_t const dynar, void *const elem)
 Returns the position of the element in the dynar. More...
 
signed int xbt_dynar_search_or_negative (xbt_dynar_t const dynar, void *const elem)
 Returns the position of the element in the dynar (or -1 if not found) More...
 
int xbt_dynar_member (xbt_dynar_t const dynar, void *const elem)
 Returns a boolean indicating whether the element is part of the dynar. More...
 
voidxbt_dynar_push_ptr (xbt_dynar_t const dynar)
 Make room at the end of the dynar for a new element, and return a pointer to it. More...
 
void xbt_dynar_push (xbt_dynar_t const dynar, const void *const src)
 Add an element at the end of the dynar. More...
 
voidxbt_dynar_pop_ptr (xbt_dynar_t const dynar)
 Mark the last dynar's element as unused and return a pointer to it. More...
 
void xbt_dynar_pop (xbt_dynar_t const dynar, void *const dst)
 Get and remove the last element of the dynar. More...
 
void xbt_dynar_unshift (xbt_dynar_t const dynar, const void *const src)
 Add an element at the begining of the dynar. More...
 
void xbt_dynar_shift (xbt_dynar_t const dynar, void *const dst)
 Get and remove the first element of the dynar. More...
 
void xbt_dynar_map (const xbt_dynar_t dynar, void_f_pvoid_t const op)
 Apply a function to each member of a dynar. More...
 
void xbt_dynar_cursor_rm (xbt_dynar_t dynar, unsigned int *const cursor)
 Removes and free the entry pointed by the cursor. More...
 
void xbt_dynar_sort (xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
 Sorts a dynar according to the function compar_fn More...
 
static int strcmp_voidp (const void *pa, const void *pb)
 
xbt_dynar_t xbt_dynar_sort_strings (xbt_dynar_t dynar)
 Sorts a dynar of strings (ie, char* data) More...
 
void xbt_dynar_three_way_partition (xbt_dynar_t const dynar, int_f_pvoid_t color)
 Sorts a dynar according to their color assuming elements can have only three colors. More...
 
voidxbt_dynar_to_array (xbt_dynar_t dynar)
 Transform a dynar into a NULL terminated array. More...
 
int xbt_dynar_compare (xbt_dynar_t d1, xbt_dynar_t d2, int(*compar)(const void *, const void *))
 Compare two dynars. More...
 

Function Documentation

XBT_LOG_NEW_DEFAULT_SUBCATEGORY ( xbt_dyn  ,
xbt  ,
"Dynamic arrays"   
)
static void _sanity_check_dynar ( xbt_dynar_t  dynar)
inlinestatic
static void _sanity_check_idx ( int  idx)
inlinestatic
static void _check_inbound_idx ( xbt_dynar_t  dynar,
int  idx 
)
inlinestatic
static void _check_populated_dynar ( xbt_dynar_t  dynar)
inlinestatic
static void _xbt_dynar_resize ( xbt_dynar_t  dynar,
unsigned long  new_size 
)
inlinestatic
static void _xbt_dynar_expand ( xbt_dynar_t const  dynar,
const unsigned long  nb 
)
inlinestatic
static void* _xbt_dynar_elm ( const xbt_dynar_t  dynar,
const unsigned long  idx 
)
inlinestatic
static void _xbt_dynar_get_elm ( void *const  dst,
const xbt_dynar_t  dynar,
const unsigned long  idx 
)
inlinestatic
static int strcmp_voidp ( const void pa,
const void pb 
)
static