Utility Functions : List of Utility Functions : stm_list_previous_id_element

stm_list_previous_id_element
Function Type
stm_list_id_elm
Description
Returns the previous item appearing in the list passed as an input argument. This function can be applied to lists containing stm_list_id_elm’s.
Note that “previous” refers to the item physically located before the current item in the list. The “current” item is determined using the utility function stm_list_last_id_element.
Syntax
stm_list_previous_id_element (list, &status)
Arguments
Input/Output
 
Status Codes
Example
In the list of states S1, S2, S3, and S4 (appearing in this order) assigned to the variable state_list, locate the state S4 by calling stm_list_last_ids_element; S4 becomes the current item. To find the previous element in the list, use the following statements:

 

stm_list state_list;
stm_id state_id;
int status;
.
.
state_id = (stm_id) stm_list_last_element (
state_list, &status);
state_id = (stm_id) stm_list_previous_id_element (
state_list, &status);
printf ("State of interest is: %s\n",
stm_r_st_name (state_id, &status));
.
.

This function can be used in a for loop (in conjunction with stm_list_last_id_element) to perform operations on all elements in the list in reverse order.