axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlListCursor* axl_list_cursor_new ( axlList list)

Allows to get a cursor to iterate the list in a linear and efficient way.

The axlListCursor could be used to iterate an axlList in an efficient way because it stores current state (position). Then using the following functions you can modify the state (current position to get):

Finally, a function is provided to get the data stored at a particular position, pointed by the current status of the cursor:

You are allowed to remove elements from the list (axlList) having a cursor created (axlListCursor), using axl_list_cursor_unlink.

Here is an example:

1 axlPointer value;
2 axlListCursor * cursor;
3 
4 // create the cursor
5 cursor = axl_list_cursor_new (list);
6 
7 // while there are more elements
8 while (axl_list_cursor_has_item (cursor)) {
9 
10  // get the value
11  value = axl_list_cursor_get (cursor);
12 
13 
14  // get the next
15  axl_list_cursor_next (cursor);
16 
17  // update the iterator
18  iterator++;
19 
20 }
21 
22 // free the cursor
23 axl_list_cursor_free (cursor);
Parameters
listThe list that the new cursor (axlListCursor) will provide access.
Returns
A newly created axlListCursor used to iterate the list. Once finished you must call to axl_list_cursor_free.

References axl_new, and axl_return_val_if_fail.