SimGrid 3.6.2
Scalable simulation of distributed systems
Functions
Heap: generic heap data structure
Usual data structures

This section describes the API to generic heap with O(log(n)) access. More...

Functions

xbt_heap_t xbt_heap_new (int num, void_f_pvoid_t const free_func)
 Creates a new heap.
void xbt_heap_free (xbt_heap_t H)
 kilkil a heap and its content
int xbt_heap_size (xbt_heap_t H)
 returns the number of elements in the heap
void xbt_heap_push (xbt_heap_t H, void *content, double key)
 Add an element into the heap.
void * xbt_heap_pop (xbt_heap_t H)
 Extracts from the heap and returns the element with the smallest key.
double xbt_heap_maxkey (xbt_heap_t H)
 returns the smallest key in the heap (heap unchanged)
void * xbt_heap_maxcontent (xbt_heap_t H)
 returns the value associated to the smallest key in the heap (heap unchanged)
void xbt_heap_set_update_callback (xbt_heap_t H, void(*update_callback)(void *, int))
 Set the update callback function.
void * xbt_heap_remove (xbt_heap_t H, int i)
 Extracts from the heap and returns the element at position i.

Detailed Description

This section describes the API to generic heap with O(log(n)) access.


Function Documentation

xbt_heap_t xbt_heap_new ( int  init_size,
void_f_pvoid_t const  free_func 
)

Creates a new heap.

Parameters:
init_sizeinitial size of the heap
free_funcfunction to call on each element when you want to free the whole heap (or NULL if nothing to do).

Creates a new heap.

void xbt_heap_free ( xbt_heap_t  H)

kilkil a heap and its content

Parameters:
Hpoor victim
int xbt_heap_size ( xbt_heap_t  H)

returns the number of elements in the heap

Parameters:
Hthe heap we're working on
Returns:
the number of elements in the heap
void xbt_heap_push ( xbt_heap_t  H,
void *  content,
double  key 
)

Add an element into the heap.

Parameters:
Hthe heap we're working on
contentthe object you want to add to the heap
keythe key associated to this object

The element with the smallest key is automatically moved at the top of the heap.

void* xbt_heap_pop ( xbt_heap_t  H)

Extracts from the heap and returns the element with the smallest key.

Parameters:
Hthe heap we're working on
Returns:
the element with the smallest key

Extracts from the heap and returns the element with the smallest key. The element with the next smallest key is automatically moved at the top of the heap.

double xbt_heap_maxkey ( xbt_heap_t  H)

returns the smallest key in the heap (heap unchanged)

Parameters:
Hthe heap we're working on
Returns:
the smallest key in the heap without modifying the heap.
void* xbt_heap_maxcontent ( xbt_heap_t  H)

returns the value associated to the smallest key in the heap (heap unchanged)

Parameters:
Hthe heap we're working on
Returns:
the value associated to the smallest key in the heap without modifying the heap.
void xbt_heap_set_update_callback ( xbt_heap_t  H,
void(*)(void *, int)  update_callback 
)

Set the update callback function.

Parameters:
Hthe heap we're working on
update_callbackfunction to call on each element to update its index when needed.
void* xbt_heap_remove ( xbt_heap_t  H,
int  i 
)

Extracts from the heap and returns the element at position i.

Parameters:
Hthe heap we're working on
ielement position
Returns:
the element at position i if ok, NULL otherwise

Extracts from the heap and returns the element at position i. The head is automatically reorded.


Back to the main Simgrid Documentation page The version of Simgrid documented here is v3.6.2.
Documentation of other versions can be found in their respective archive files (directory doc/html).
Generated for SimGridAPI by doxygen