prg_list_map()
Abstract
Applies the map function to elements of the list_ptr list.
Syntax
prg_list_map (list_ptr, mapfun, state)
| Argument | Type | Description |
|---|---|---|
list_ptr |
PrgT_List* |
pointer to the list-of-interest |
mapfun |
PrgT_List_Map_Proc | function applied to elements of the list. |
state |
Vartype* |
state data passed to mapfun when mapfun is called. |
Return Type
void
No return value
Header
prg_list_funcs.h
Example:
/* read a GDF file */
routing_list_ptr = prg_gdf_read ("routing_table");
/* Print out the contents of the list by applying */
/* the ’printf’ function to its elements. */
prg_list_map (routing_list_ptr, printf, "%s\n");
Details
The mapping function mapfun is applied to each element of the list, starting at the head, until all elements are visited, or mapfun returns 0. The prototype for mapfun is given in PrgT_List_Map_Proc.
WARNING: This function is MT unsafe, as described in “Multi-Threading Safety“ on page 11. Access to shared lists must be externally serialized.
Purpose:
Iterates through the specified list, applying a user-specified function to some or all of its elements.
Errors:
- Program Abort: Segmentation violation (due to an invalid list pointer or malformed list)
Reference:
- None